addConditionalFormatting
Apply conditional formatting rules to spreadsheet ranges so cells automatically change style—background, bold, or text color—when values meet numeric, blank, or custom-formula conditions.
Instructions
Adds a conditional formatting rule to one or more ranges in a spreadsheet. Applies a format (background color, bold, text color, etc.) when cells meet a specified condition. Use CUSTOM_FORMULA for complex conditions like "=$A1>$B1". Note: each call appends a new rule — use deleteConditionalFormatting to remove existing rules before re-adding.
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": {
"spreadsheetId": "<spreadsheetId>",
"ranges": "<ranges>",
"conditionType": "<conditionType>"
},
"name": "addConditionalFormatting"
}
}Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| bold | No | Apply bold text formatting. | |
| italic | No | Apply italic text formatting. | |
| ranges | Yes | One or more A1 notation ranges the rule applies to (e.g., ["B2:S68"] or ["A1:A10", "C1:C10"]). | |
| fontSize | No | Font size in points. | |
| sheetName | No | Name of the sheet/tab. Defaults to the first sheet if not provided. | |
| underline | No | Apply underline text formatting. | |
| conditionType | Yes | The condition type. NUMBER_* types compare cell values numerically. CUSTOM_FORMULA evaluates a formula (e.g., "=$A1>10"). BLANK/NOT_BLANK check whether a cell is empty. | |
| spreadsheetId | Yes | The spreadsheet ID — the long string between /d/ and /edit in a Google Sheets URL. | |
| strikethrough | No | Apply strikethrough text formatting. | |
| backgroundColor | No | Cell background color as hex (e.g., "#FF9900"). | |
| conditionValues | No | Values for the condition. Omit or pass [] for BLANK and NOT_BLANK. Pass one value for all NUMBER_* single-operand types and CUSTOM_FORMULA. Pass two values for NUMBER_BETWEEN and NUMBER_NOT_BETWEEN (lower bound first). | |
| foregroundColor | No | Text (foreground) color as hex (e.g., "#FF0000"). |