Hello, Guys welcome back to learn How to Make your Documents Read-only in Google Drive. Your documents and files in Google Drive can be modified by anyone who has edit access to the file. Learn how to freeze a document and prevent anyone from editing your files.
By default, the files in your Google Drive are private, and only the owner has the ability to view, edit, or delete them. If you choose to share a file with others, you can specify whether they have read-only access to your files or if they may modify and comment on them.
- Request Additional Quota for your YouTube API Project
- How to Get Email Alerts When Files are Deleted in your Drive
You can always remove external collaborators from your papers to prevent others from modifying your files, but how do you keep yourself (the owner) from editing your own files in Google Drive?

How to Prevent Document Edits in Google Drive
Google Drive now has a new Locking API that allows developers to simply add content limitations to documents, spreadsheets, presentations, PDFs, and other Google Drive files.
When you lock a file, no one (including the owner) can make changes to it, the file title cannot be changed, and the option of commenting inside files is removed.
Because Google Drive doesn’t have an easy button for locking files (yet), here’s a Google Script that will allow you to make any file in your Google Drive read-only.
1. Open Google Drive and right-click on any file you want to designate read-only. Copy the file link to the clipboard by clicking the Share Link menu.
https://docs.google.com/spreadsheets/d/12345_abcdef-123/edit?usp=sharing
2. To open a new Google Apps Script project, type script.new in the browser and paste this snippet into the code editor.
/**
* Make Google Drive files Read only
* Author: [email protected]
* Web: https://digitalinspiration.com/
* MIT License
**/
const makeFileReadyOnly = () => {
const fileUrl = '<<FILE URL>>';
const [fileId] = fileUrl.split('/').filter((e) => /[_-\w]{25,}/.test(e));
UrlFetchApp.fetch(`https://www.googleapis.com/drive/v3/files/${fileId}`, {
method: 'PATCH',
contentType: 'application/json',
headers: {
Authorization: `Bearer ${ScriptApp.getOAuthToken()}`,
},
payload: JSON.stringify({
contentRestrictions: [
{
readOnly: true,
reason: 'Prevent accidental editing',
},
],
}),
});
// For requesting correct scope, do not delete
// var file = DriveApp.getFileById().setName()
};
3. Replace the FILE URL
in line #2 with the URL of the Drive file that you copied in the previous step.
4. Navigate to the Run menu and select Run function > makeFileReadyOnly. Accept the permissions, and anyone, including yourself, will be unable to alter your file.
To restore the editing behaviour and remove the file lock, open Google Drive, right-click the same file, and select “Unlock file” from the menu.

Please do note that when you freeze a document with the Google Drive Lock API, even Google Scripts and Google Workspace add-ons are blocked from editing the file.