[codefix]
Formats a TypeScript or JavaScript document with TypeScript language-service edits.
Editor and agent workflows often need preview-first writes and in-memory text to stay aligned while planning or validating edits.
The model can preview disk writes, preserve live document version guards, and keep semantic reads aligned with fresh edits.
Try it locally in the TGlider playground
| Name | Type | Required | Description |
|---|---|---|---|
| filePath | string | Yes | Workspace-relative or absolute file path. |
| applyChanges | boolean | No | Apply formatting edits to live workspace state instead of returning preview only. |
| includeDiff | boolean | No | Include a unified diff in the response. |
| maxDiffChars | number | No | Maximum diff characters to return before truncating. |
| indentSize | number | No | Indent width to use for formatting. Defaults to the document indentation style. |
| tabSize | number | No | Tab width to use for formatting. Defaults to the document indentation style. |
| convertTabsToSpaces | boolean | No | Use spaces instead of tabs for indentation. Defaults to the document indentation style. |
| semicolons | string | No | Semicolon preference: 'ignore', 'insert', or 'remove'. Defaults to preserving existing semicolon style. |
Preview formatting edits
{
"jsonrpc": "2.0",
"id": 1,
"method": "tools/call",
"params": {
"name": "format_document",
"arguments": {
"filePath": "src/app.ts"
}
}
}Returns formatting edits, preview diff metadata, live-document version state, and whether changes were applied.