VS Code has a built-in JSON formatter that works reliably when the JSON is syntactically valid.
Loading JSON Formatter…
Diagnoses errors VS Code will not format
Matches VS Code 2-space default indentation
Works in any browser without extensions
Instant feedback on syntax problems
Drop the JSON Formatter into any page — blog post, product docs, intranet, school portal — with a single line of HTML. Your visitors get the full tool, processed entirely in their browser. No backend, no uploads, no signup.
Embed code
<iframe
src="https://www.fixtools.io/json/json-formatter?embed=1"
width="100%"
height="780"
frameborder="0"
style="border:0;border-radius:16px;max-width:900px;"
title="JSON Formatter by FixTools"
loading="lazy"
allow="clipboard-write"
></iframe>Attribution-friendly: a small "Powered by FixTools" link appears in the embed footer.
VS Code ships with a built-in JSON language server that provides formatting, validation, autocompletion, and hover documentation for JSON files. The formatter is triggered by the Format Document command (Shift+Alt+F on Windows and Linux, Shift+Option+F on macOS) or automatically when the editor.formatOnSave setting is enabled. However, the VS Code JSON formatter requires the file to be syntactically valid before it will produce output. If the file contains a syntax error, the formatter returns early and leaves the document unchanged. The editor may show a red squiggle at or near the error position, but the associated error message is sometimes as unhelpful as "Expected comma" without indicating which expected comma at which location.
The VS Code JSON language server is built on the vscode-json-languageservice npm package, which uses the jsonc-parser library internally. This parser accepts JSONC (JSON with Comments), which is why files with a .jsonc extension and VS Code's own settings.json and extensions.json can contain // single-line and /* */ block comments. Pure .json files are validated more strictly against the RFC 8259 standard. When you run Format Document and nothing happens, the most likely cause is a syntax error that the language server has detected but has not surfaced prominently in the editor UI. The Problems panel accessible via View > Problems lists all detected errors with file name, line number, and a text description, and is more informative than the editor squiggle alone.
Pasting the JSON into FixTools is the fastest way to identify and fix the exact syntax error before returning to VS Code. FixTools uses the browser's native JSON.parse(), which is RFC 8259-compliant and reports the exact character position of the first error it encounters. The error message from the browser's JSON parser is often more precise than the one VS Code surfaces in its Problems panel, because it reports the character the parser actually encountered rather than the character it was waiting for. Once you fix the error and copy the formatted output back into VS Code, the file is valid and VS Code's own formatter and language server features will work normally for all subsequent edits.
VS Code users hit a recurring confusion around JSON5 and JSONC. The editor recognises three flavors: strict .json files which forbid comments and trailing commas, .jsonc files which allow both, and JSON5 files which require the vscode-json5 extension to handle the wider grammar including unquoted keys and single-quoted strings. Default settings.json, keybindings.json, and tsconfig.json are treated as JSONC by file association rules in VS Code's package.json. If you copy a tsconfig.json into a tool that does not understand JSONC, including FixTools or a build script that uses strict JSON.parse, the comments will trigger errors. Strip them with a JSONC preprocessor such as the jsonc-parser npm package, or rename the file to .jsonc and accept that downstream tooling needs JSONC support.
VS Code's built-in JSON formatter and Prettier behave differently enough on edge cases to be worth distinguishing. The built-in formatter uses your editor.tabSize and editor.insertSpaces settings, applies them globally to all JSON files in the workspace, and runs synchronously on Format Document. Prettier reads its own .prettierrc and ignores VS Code editor settings, runs asynchronously through the VS Code Prettier extension or via a pre-commit hook, and handles a broader range of file types with one shared configuration. For team consistency, Prettier wins because the .prettierrc lives in the repository and applies identically across every developer's machine regardless of their individual editor preferences. For a single-developer hobby project, the built-in formatter is sufficient and avoids the dependency on a Node-based formatter binary.
Paste the JSON from your VS Code file here to identify syntax errors, fix them, and get clean formatted output ready to paste back.
Step-by-step guide to format json in vs code, and what to do when it fails:
Copy from VS Code
Select all content in your VS Code JSON file using Ctrl+A (Windows/Linux) or Cmd+A (macOS) and copy it to your clipboard. Include the full file content so the validator can check the complete structure including the opening and closing brackets.
Paste into FixTools
Paste the JSON into the FixTools JSON Formatter input area. The editor accepts the full file content regardless of its current indentation or whether it contains syntax errors.
Review the error
If the JSON is invalid, FixTools highlights the error position in the input and displays a message explaining what is wrong, including the line and column number where the parser detected the problem.
Fix and format
Correct the syntax error in the input field, then click Format. If the fix was correct, the formatted output appears. If there are additional errors, the next one is reported for you to address.
Paste back into VS Code
Copy the formatted output and paste it into VS Code, replacing the original file content. The file is now valid and VS Code's formatter and IntelliSense will work on it normally.
Common situations where this approach makes a real difference:
A developer edits a tsconfig.json file manually, accidentally leaving a trailing comma after the last compiler option key. VS Code shows a red squiggle but Format Document does nothing and the Problems panel message is not specific enough to locate the comma. Pasting into FixTools flags the exact line and column of the trailing comma, allowing the developer to remove it and paste the corrected file back in under 30 seconds.
Trailing commas are the most common reason VS Code refuses to format JSON config files like tsconfig.json and package.json.
A DevOps engineer copies a JSON configuration snippet from a Slack message into a VS Code Kubernetes manifest. The snippet used single-quoted string values instead of double-quoted strings because the sender copied it from a Python dictionary literal. VS Code underlines the first single-quoted value but the error description is unclear. FixTools explains that all strings must be double-quoted per RFC 8259 and identifies every single-quoted string in the document.
Single-quoted strings from Python or JavaScript source code frequently appear in JSON files pasted from chat or documentation.
A developer has a large package.json with a missing comma between two dependency entries that were added in two separate editing sessions. VS Code's squiggle appears several lines below the actual missing comma because the parser reports the position where it first detects a problem, not where the comma should have been. FixTools gives the same error position but with the surrounding context visible in the formatted output, making the correct insertion point clear.
JSON parser error positions often point to the next unexpected token rather than the location of the actual missing character.
A developer new to the team is not yet familiar with VS Code keyboard shortcuts and does not know how to trigger Format Document or where to find the Problems panel. They use FixTools as an accessible alternative: paste the file, click Format, copy the result. This workflow produces correctly formatted JSON without requiring knowledge of VS Code settings, extension configuration, or the specific keyboard shortcut for the format command.
Browser-based formatters are accessible to developers regardless of their familiarity with VS Code's interface.
Get better results with these expert suggestions:
Enable formatOnSave in VS Code for JSON
Add "editor.formatOnSave": true to your VS Code user or workspace settings.json. To apply this setting only to JSON files, use the language-scoped override: "[json]": { "editor.formatOnSave": true }. This automatically formats your JSON file on every save as long as it is valid. Combine it with Prettier (esbenp.prettier-vscode extension) and a .prettierrc file to ensure consistent indentation across all team members.
Use the Problems panel for JSON errors
When VS Code refuses to format a JSON file, open the Problems panel with Ctrl+Shift+M (Windows/Linux) or Cmd+Shift+M (macOS). The JSON language server lists all detected syntax errors with the file path, line number, column, and a text description. This panel shows all errors simultaneously rather than one at a time, which is faster for fixing files with multiple issues.
JSONC vs JSON in VS Code
VS Code treats files with the .jsonc extension as JSON with Comments, allowing // and /* */ comments. If you need to add explanatory comments to a JSON config file, rename it to .jsonc so VS Code handles it with the more permissive JSONC parser. The tsconfig.json file is already treated as JSONC by VS Code, which is why it accepts comments despite having a .json extension.
Install Prettier for consistent team JSON formatting
The Prettier VS Code extension (esbenp.prettier-vscode) formats JSON files using a shared .prettierrc configuration committed to the repository. This ensures every team member produces the same indentation, quote style, and line endings regardless of their individual VS Code settings. Run Prettier as a pre-commit hook and in your CI pipeline to enforce the standard before code is merged.
More use-case guides for the same tool:
Other tools you might find useful:
Open the full JSON Formatter — free, no account needed, works on any device.
Open JSON Formatter →Free · No account needed · Works on any device