fix-json uses jsonic to parse JSON data
in the current editor, then reformats the content using JSON.stringify.
You can enter JSON data using the relaxed rules supported by jsonic. For instance, quotes around property names and many string values are not required. This makes it much easier to type JSON, or to convert JavaScript objects into valid JSON.
- Fix JSON command: Run the
Fix JSONcommand to fix either the selected content in the active editor or the whole document if there is no selection. - Format Document integration: Use the standard VS Code "Format Document" action on JSON files to apply the same fixing/formatting logic.
If errors are encountered during parsing, they are shown as editor diagnostics (squiggles) with a message in the status bar.
The extension indents the generated JSON using a default number of spaces as
configured in your editor.tabSize setting. You can use the setting
fixJson.indentationSpaces to override the number specifically for this
extension.
No effort is made to provide formatting beyond the standard output from
JSON.stringify(text, null, indentation). I recommend using
Prettier.
- Currently this extension targets JSON only. JSON with comments (JSONC) is not supported by the parser in use at this time.
- VS Marketplace: https://marketplace.visualstudio.com/items?itemName=oliversturm.fix-json
- Open VSX: https://open-vsx.org/extension/oliversturm/fix-json
- Manual: Download a
.vsixfrom the GitHub Releases page and install via the command palette (Extensions: Install from VSIX...).
- Run the
Fix JSONcommand from the Command Palette. - Or use "Format Document" on a JSON file. On first use, select "Fix JSON" as the default formatter for JSON if prompted.
This extension contributes the following settings:
fixJson.indentationSpaces: Number of spaces to use for indentation of formatted JSON output. If not set, your editor.tabSize setting is used.
- Run & debug: F5 (launches an Extension Development Host).
- Tests:
npm test(Mocha unit tests of the core logic inlib/fixText.js). - Lint:
npm run lint(ESLint v9 flat config). - Package:
npm run package(produces a.vsix).
- CI (
.github/workflows/ci.yml) runs on pushes/PRs to the default branch: installs, lints, tests, and packages the extension; uploads the.vsixartifact. - Releases (
.github/workflows/release.yml) run on tags matchingv*.*.*or via manual dispatch. Publish steps require repository secrets:VSCE_PATfor VS MarketplaceOVSX_PATfor Open VSX
See CHANGELOG.md for notable changes.

