To validate JSON in VS Code, open the document in JSON language mode, use the Problems panel to fix syntax diagnostics, and use a local JSON Validator when you need a strict second verdict with the exact error line and column.

VS Code can expose malformed JSON as you edit, but several related questions are easy to mix: strict syntax, JSON Schema compliance, and whether the data matches what an application expects. Keeping those checks separate prevents a successful parser result from being mistaken for a successful API response.

how to validate json in vscode
Validate JSON in VS Code: Catch Syntax Errors Precisely

What VS Code checks while you type

VS Code includes built-in support for JSON documents. When it recognizes a file’s language as JSON, syntax problems appear as editor diagnostics and in the Problems panel. If a pasted document is still treated as plain text, click the language indicator in the status bar and select JSON, or use the Command Palette, choose “Change Language Mode,” and select JSON.

The first layer is syntax. A missing comma, invalid quote, or unmatched brace is a parser problem. VS Code can also apply JSON Schema rules, including associations configured through the json.schemas setting. Schema errors therefore are not the same thing as invalid JSON: a file can be syntactically correct while missing a required field or containing a value of the wrong type.

Language mode can also change strictness. Some VS Code configuration documents use JSON with Comments, so comments or trailing commas may be accepted by the editor but rejected by a strict runtime. The RFC 8259 grammar defines standard JSON, while the browser validator described below deliberately follows that strict form.

Validate a JSON file in VS Code

  1. Open the document. Use File > Open File for a saved .json file, or create and paste one into the editor. If the status-bar language indicator does not say JSON, set it to JSON before judging the diagnostics.
  2. Open the Problems panel. Choose View > Problems, or press Ctrl+Shift+M on Windows and Linux or Cmd+Shift+M on macOS. Review the JSON diagnostics, starting with the earliest reported error because a parser may stop at the first broken token.
  3. Jump to the failure. Click a problem entry to move to its line and column. Hover over the red squiggle to read the diagnostic message, then inspect the characters around that location instead of changing a distant part of the file.
  4. Correct and recheck. Fix the reported syntax issue and let VS Code refresh the Problems panel. Repeat until no syntax diagnostics remain, keeping parser errors separate from any schema warnings.
  5. Add schema checks when needed. If the file is valid but an application still rejects it, inspect the json.schemas setting and associate the relevant file pattern with an appropriate schema. This can expose missing required fields, incorrect value types, and other contract mismatches.
  6. Run a strict final check. Copy the final document text and perform the browser check below. This confirms the payload as standard JSON, rather than only as a document accepted by the editor’s current language mode.

Run an independent strict check

For payloads that will be sent to an API, read from a file, or parsed by JavaScript, use the JSON Validator as an independent strict-syntax pass. It is a separate browser page rather than a VS Code extension. Validation runs entirely in the browser, so the pasted JSON is not uploaded to a server.

  1. Select and copy the complete JSON text from VS Code, including the opening and closing braces or brackets.
  2. Open JSON Validator and paste or type the text into its input box.
  3. Read the verdict immediately: a green “Valid JSON” result, or a red error containing the parser message and the line and column where parsing failed.
  4. For a red result, note the reported position, return to VS Code, and jump to that line and column. Fix the source document rather than editing a separately reformatted copy.
  5. For a green result, review the structure report: top-level type, maximum nesting depth, total key count across all levels, object and array counts, and character count.
  6. Return to VS Code and keep the corrected document as the source of truth. If another edit changes the payload, validate it again.

Read the verdict and diagnostic

The browser validator uses the browser’s native JSON.parse implementation, which follows the ECMA-404 and RFC 8259 grammar. Its strict verdict therefore reflects standard JSON rather than a lenient editor mode. Error wording can differ among browsers, but the tool normalizes the position reported by the underlying engine, so you can use the line and column to navigate back to the source.

Signal or check What VS Code provides What JSON Validator provides
Syntax feedback Red squiggles and Problems-panel entries as the editor analyzes the document. A green “Valid JSON” verdict or a red parser error with a reported line and column.
Strictness Depends on the selected language mode; JSON with Comments can differ from strict JSON. Uses native JSON.parse and the strict RFC 8259 grammar.
Schema checks Can report contract issues when a document is associated with a JSON Schema. Checks syntax and reports structure; it does not evaluate a JSON Schema.
Structure summary Provides the selected diagnostics rather than one aggregate structure report. Shows type, maximum depth, total key count, object and array counts, and character count.
Formatting Can format JSON documents. Leaves the pasted text unchanged and does not beautify or minify it.

Treat the structure report as a sanity check, not a schema verdict. A response can be valid JSON yet still have an unexpected top-level type, unusually deep nesting, or a different key count from what the consuming code expects.

Common strict-JSON failures

Most documents that “look fine” fail because of strictness rules rather than damaged data. The browser validator rejects these common forms:

Invalid form Reason Valid equivalent
{ 'name': 'Ada' } JSON keys and strings require double quotes. { "name": "Ada" }
{ name: "Ada" } Object keys cannot be left unquoted. { "name": "Ada" }
{ "items": [1, 2,], } Trailing commas are not allowed after array or object elements. { "items": [1, 2] }
{ /* note */ "ok": true } Comments are not part of standard JSON. { "ok": true }
{ "value": NaN } NaN and Infinity are not valid JSON numbers. { "value": 123 }
{ "items": [1, 2 } Every array and object bracket must be balanced and correctly closed. { "items": [1, 2] }

Also remember that a double quote inside a string must be escaped with a backslash, while the literal values true, false, and null are lowercase. The validator does not auto-repair these issues, so the reliable loop is edit, validate, and repeat.

What a valid result does not prove

A green verdict proves syntax, not application correctness. The validator does not know which properties your API requires, which values are allowed, or whether identifiers and timestamps make sense. Keep VS Code’s JSON Schema association for contract-level checks, and use runtime tests for business behavior.

Numbers need a special caveat. JSON numbers are read as IEEE-754 doubles, so integers beyond 2^53 can lose precision even though the document passes validation. If exact large integers matter, inspect those values in the editor or the consuming system rather than relying on the syntax verdict alone.

The validator is not a formatter. It does not beautify, minify, or silently rewrite your input; its purpose is correctness checking, error localization, and structural diagnostics. This makes it suitable for API responses, configuration text, and other payloads where preserving the original characters matters.

A repeatable two-stage routine

A concise routine prevents most repeat failures:

  • Confirm that VS Code recognizes the document as JSON rather than plain text or JSON with Comments.
  • Resolve every syntax entry in the Problems panel and click each location to verify the correction.
  • Apply a JSON Schema association when the file has an expected structure or API contract.
  • Copy the final text into JSON Validator and confirm the green “Valid JSON” verdict.
  • Review the type, nesting depth, key count, and payload size for an unexpected response shape.
  • Test the consuming application separately for schema, business-rule, and runtime behavior.

If you're weighing options, Java Convert Properties to JSON: Reader-Style Workflow covers this in detail.

If you're weighing options, Decode ULID Timestamp: Command Line vs Online covers this in detail.