Find and Replace Doc
find_and_replace_docFind and replace text throughout a Google Doc without calculating indices, enabling safe updates to placeholders, phrases, and targeted content.
Instructions
Finds and replaces text throughout a Google Doc. No index calculation required.
This is the safest way to update specific text in a document because it does not require knowing any indices. Use this tool when you need to:
Replace placeholder text (e.g., {{TITLE}}) with real content
Update specific words or phrases throughout the document
Make targeted text changes without risk of index errors
For building documents from scratch, consider inserting text with unique placeholders via batch_update_doc, then using this tool to replace them.
Tool call template
Replace each placeholder with a value matching the input schema. Only required parameters are included; add optional parameters as needed.
{
"id": 1,
"jsonrpc": "2.0",
"method": "tools/call",
"params": {
"arguments": {
"user_google_email": "<user_google_email>",
"document_id": "<document_id>",
"find_text": "<find_text>",
"replace_text": "<replace_text>"
},
"name": "find_and_replace_doc"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| tab_id | No | Optional ID of the tab to target | |
| find_text | Yes | Text to search for | |
| match_case | No | Whether to match case exactly | |
| write_mode | No | "EDIT" (default) applies the replacements directly; "SUGGEST" records them as suggested edits that collaborators can accept or reject | EDIT |
| document_id | Yes | ID of the document to update | |
| replace_text | Yes | Text to replace with | |
| user_google_email | Yes | User's Google email address |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |