modify_doc_text
Insert, replace, or format text in Google Docs with options for markdown conversion and precise positioning.
Instructions
Modifies text in a Google Doc - can insert/replace text and/or apply formatting in a single operation.
TIP: To append text to the end of the document without calculating indices, set end_of_segment=true. This avoids index calculation errors.
MARKDOWN MODE: Set format_as_markdown=True to parse text as markdown and
insert it with native Docs formatting (headings, bold, italic, bullets,
numbered lists). Works for both plain insertion and range replacement.
When enabled, explicit formatting parameters (bold, italic, font_size, etc.)
must NOT be set — markdown brings its own formatting.
For ordinary header/footer text, prefer update_doc_headers_footers. Only pass segment_id when you already have a real header/footer/footnote segment ID from inspect_doc_structure output. Do not guess IDs such as "kix.header" or "kix.footer".
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| user_google_email | Yes | User's Google email address | |
| document_id | Yes | ID of the document to update | |
| start_index | Yes | Start position for operation using Docs API indices from inspect_doc_structure. For the main body, 0 is also accepted as an alias for the first writable position. | |
| end_index | No | End position for text replacement/formatting (if not provided with text, text is inserted) | |
| text | No | New text to insert or replace with (optional - can format existing text without changing it) | |
| tab_id | No | Optional document tab ID to target | |
| segment_id | No | Optional header/footer/footnote segment ID to target | |
| end_of_segment | No | Insert text at the end of the targeted segment instead of start_index | |
| bold | No | Whether to make text bold (True/False/None to leave unchanged) | |
| italic | No | Whether to make text italic (True/False/None to leave unchanged) | |
| underline | No | Whether to underline text (True/False/None to leave unchanged) | |
| strikethrough | No | Whether to strike through text (True/False/None to leave unchanged) | |
| font_size | No | Font size in points | |
| font_family | No | Font family name (e.g., "Arial", "Times New Roman") | |
| font_weight | No | Font weight (100-900 in steps of 100; requires font_family) | |
| text_color | No | Foreground text color (#RRGGBB) | |
| background_color | No | Background/highlight color (#RRGGBB) | |
| link_url | No | Hyperlink URL (http/https) | |
| clear_link | No | Remove hyperlink from the target range | |
| baseline_offset | No | One of NONE, SUPERSCRIPT, SUBSCRIPT | |
| small_caps | No | Whether to apply small caps | |
| format_as_markdown | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |