Skip to main content
docx_format Change text and paragraph formatting. To format multiple items at once, use docx_mutations with format.apply steps instead of calling this tool repeatedly. Use require “all” with a node selector to format every heading or paragraph in one batch. Use this tool for single-item formatting when you have a valid ref or nodeId. Action “inline” applies character formatting (bold, italic, underline, color, fontSize, fontFamily, highlight, strike, vertAlign) to a text range via “ref”. Action “set_style” applies a named paragraph style by styleId (get available styles from docx_get_content info). Actions “set_alignment”, “set_indentation”, “set_spacing”, “set_direction”, and “set_flow_options” change paragraph-level properties and require a block target: {kind:“block”, nodeType:“paragraph”, nodeId:“<nodeId>”}, NOT a ref. Use “set_flow_options” with pageBreakBefore:true to start a paragraph on a new page. Supports “dryRun” and “changeMode: tracked” for inline formatting. Paragraph-level actions do NOT support tracked changes. Do NOT use a search ref for paragraph-level actions; they require a block target with nodeId. Do NOT use {kind:“block”, start:{kind:“nodeEdge”,…}} or selection-like structures for paragraph actions. ONLY {kind:“block”, nodeType, nodeId} is accepted. Do NOT issue multiple docx_format calls in parallel; each call invalidates refs for subsequent calls.

Parameters

string, enum: 'inline' | 'set_alignment' | 'set_direction' | 'set_flow_options' | 'set_indentation' | 'set_spacing' | 'set_style'
required
The action to perform. One of: inline, set_alignment, set_direction, set_flow_options, set_indentation, set_spacing, set_style.
boolean
Bypass confirmation checks.
string, enum: 'direct' | 'tracked'
Edit mode: “direct” applies changes immediately, “tracked” records as suggestions.
boolean
Preview the result without applying changes.
object
Selection target: {kind:‘selection’, start:{kind:‘text’, blockId, offset}, end:{kind:‘text’, blockId, offset}}. Use ‘ref’ instead when you have a search result handle. Required for actions ‘set_style’, ‘set_alignment’, ‘set_indentation’, ‘set_spacing’, ‘set_flow_options’, ‘set_direction’.
object
Inline formatting properties to apply. Set a property to apply it, use null to clear it. Example: {bold: true, italic: true} or {bold: null} to remove bold. Only for action ‘inline’. Omit for other actions.
string
Handle ref string from a docx_search result. Pass the handle.ref value directly (e.g. ‘text:eyJ…’). Preferred over ‘target’ for inline formatting. Only for action ‘inline’. Omit for other actions.
string
Named paragraph style ID (e.g. ‘Normal’, ‘Heading1’, ‘BodyText’). Use docx_search to find a nearby paragraph, then inspect its style to determine the correct styleId. Required for action ‘set_style’.
string, enum: 'left' | 'center' | 'right' | 'justify'
Required for action ‘set_alignment’.
number
Left indentation in twips (1440 = 1 inch). Only for action ‘set_indentation’. Omit for other actions.
number
Right indentation in twips (1440 = 1 inch). Only for action ‘set_indentation’. Omit for other actions.
number
First line indent in twips. Cannot be combined with hanging. Only for action ‘set_indentation’. Omit for other actions.
number
Hanging indent in twips. Cannot be combined with firstLine. Only for action ‘set_indentation’. Omit for other actions.
number
Space before paragraph in twips (20 twips = 1pt). Only for action ‘set_spacing’. Omit for other actions.
number
Space after paragraph in twips (20 twips = 1pt). Only for action ‘set_spacing’. Omit for other actions.
number
Line spacing value. Meaning depends on lineRule. Must be provided together with lineRule. Only for action ‘set_spacing’. Omit for other actions.
string, enum: 'auto' | 'exact' | 'atLeast'
Line spacing rule. Required when ‘line’ is set. Only for action ‘set_spacing’. Omit for other actions.
boolean
Only for action ‘set_flow_options’. Omit for other actions.
boolean
Only for action ‘set_flow_options’. Omit for other actions.
boolean
Only for action ‘set_flow_options’. Omit for other actions.
string, enum: 'ltr' | 'rtl'
Required for action ‘set_direction’.
string, enum: 'preserve' | 'matchDirection'
Only for action ‘set_direction’. Omit for other actions.
string
required
The HERO documentId of the docx to target.