Skip to content
| Marketplace
Sign in
Visual Studio Code>Linters>JSON Lens CompareNew to Visual Studio Code? Get it now.
JSON Lens Compare

JSON Lens Compare

Marabunta

| (0) | Free
Validate, format, sort and compare JSON with precise error messages.
Installation
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
Copied to clipboard
More Info

JSON Lens

Validate, format, sort and compare JSON, with error messages that tell you what is wrong and where.

In the editor

With a JSON file open, run from the Command Palette or the editor's right-click menu (JSON Lens submenu):

Command What it does
JSON Lens: Format Pretty-prints the file (or just the selection).
JSON Lens: Minify Removes all whitespace.
JSON Lens: Sort Keys Sorts every object's keys, at every level, and formats.
JSON Lens: Validate Checks the file and lists problems in the Problems panel.

If the JSON is invalid nothing is rewritten: the cursor jumps to the first error, which is also shown in the Problems panel (it disappears as soon as you edit). Selections are processed on their own, leaving the rest of the file untouched. Line endings and a final newline are preserved.

Setting Default Description
json-lens.indent editor editor follows the editor's own indentation; or 2, 4, tab.
json-lens.sortOrder asc asc (A → Z) or desc (Z → A) for Sort Keys.

Compare panel

Open the JSON Lens view in the Activity Bar and press Open JSON Lens (or run JSON Lens: Open). You get two boxes, A and B: paste JSON into each, or load a file.

Features

  • Strict validation. Every box is checked as you type. An error shows the line and column, a plain explanation and the offending line with a caret; Go to error selects it in the box. Typical mistakes are named: trailing commas, comments, single quotes, unquoted keys, NaN / undefined, leading zeros, unescaped line breaks in strings, unclosed brackets (and where they were opened), several documents in one file…
  • Duplicate keys are flagged as warnings (valid JSON, but most parsers silently keep only the last value).
  • Format / Minify with 2 spaces, 4 spaces or tabs. Numbers and string escapes are kept exactly as written, so large integers such as 12345678901234567890 are never altered.
  • Sort keys (A → Z or Z → A, at every nesting level) so two files can be compared line by line.
  • Compare A with B by value: key order, spacing and number/escape spelling (1.0 vs 1, é vs é) do not count as differences.
    • Differences: a list by path ($.user.tags[2], $["odd key"]) with what was added, removed or changed.
    • Side by side: both documents with keys sorted, showing only the changes plus context.
    • Ignore array order: match array elements by content instead of by position.
    • The result updates while you edit.
  • Load / Save files, Swap A and B.

Limits (v0.1)

  • Strict JSON only (RFC 8259): JSON with comments (JSONC) or JSON5 is reported as invalid.
  • The parser stops at the first error.
  • Up to 50 MB per loaded file; very large inputs make the side-by-side view fall back to showing the changed block as replaced.

Development

npm install
npm test           # core tests (node:test)
npm run compile    # type-check + lint + bundle
# F5 in VS Code runs the extension; samples/ has a.json, b.json and broken.json to try

Created by Marabunta Labs.

  • Contact us
  • Jobs
  • Privacy
  • Manage cookies
  • Terms of use
  • Trademarks
  • Your Privacy Choices
  • Consumer Health Privacy
© 2026 Microsoft