Skip to content
How-To

How to Validate JSON in VS Code: Complete 2026 Guide

·8 min read

You just opened a JSON config file in VS Code. Something looks off, but you can't tell what. Is there a missing comma? A rogue trailing bracket? You need to validate it - fast.

Here's the good news: VS Code is one of the best JSON editors on the planet. It ships with built-in validation, formatting, and even schema support. You probably already have everything you need - you just don't know it yet.

This guide walks you through every way to validate JSON in Visual Studio Code - from the features that work out of the box to the extensions that take it further. And we'll cover the situations where VS Code isn't the right tool for the job.

VS Code Validates JSON Out of the Box

Most developers don't realize this, but VS Code already includes a built-in JSON language server. The moment you open a .json file, it starts working. No extensions needed. No configuration required.

The built-in validator catches the errors that waste the most time - the ones from our common JSON errorsguide. Trailing commas, single quotes instead of double quotes, missing brackets, comments where they don't belong. VS Code underlines them in red and shows you the exact problem in the Problems panel.

Try it yourself. Create a file called test.json and paste this:

{
  "name": "test",
  "version": "1.0",
  "active": true,
}

See that trailing comma after true? VS Code will immediately flag it with a red squiggly line. Hover over it, and you get a clear message: "Trailing comma". That alone saves you from one of the most frequent JSON headaches.

The validator also checks structural integrity. Mismatched braces, unclosed strings, duplicate keys - all flagged instantly as you type. No save required. No build step. It just works.

How to Format and Auto-Fix JSON in VS Code

Validation tells you something is wrong. Formatting helps you see it. And in VS Code, formatting JSON is one keyboard shortcut away.

Open any JSON file and press Shift+Alt+F on Windows or Shift+Option+F on Mac. VS Code will pretty-print the entire file with proper indentation. Minified JSON that looked like one impossible line becomes readable in a second.

You can also format a selection. Highlight just the part you want to clean up, then press Ctrl+K Ctrl+F. This is useful when you're working in a larger file and only want to reformat a specific block.

Want auto-formatting on every save? Add this to your VS Code settings (settings.json):

{
  "[json]": {
    "editor.defaultFormatter": "vscode.json-language-features",
    "editor.formatOnSave": true
  }
}

Now every time you save a JSON file, it gets formatted automatically. No more arguments about tabs versus spaces - the formatter handles it. If you need a deeper dive into formatting options, check our complete guide to formatting JSON.

JSON Schema Validation in VS Code

Here's where VS Code gets seriously powerful. Syntax validation catches broken JSON. Schema validation catches wrong JSON - the kind that parses fine but has the wrong structure, missing fields, or invalid values.

VS Code supports JSON Schema out of the box. It even ships with schemas for common files like package.json, tsconfig.json, and .eslintrc. That's why you get autocomplete suggestions when editing those files - VS Code knows their structure.

You can add your own schema mappings in settings.json:

{
  "json.schemas": [
    {
      "fileMatch": ["*.config.json"],
      "url": "./schemas/config-schema.json"
    },
    {
      "fileMatch": ["api-response.json"],
      "url": "https://example.com/schemas/api-response.json"
    }
  ]
}

Once a schema is mapped, VS Code does more than highlight errors. It gives you autocomplete for valid keys, shows documentation on hover, and validates that values match the expected types. If your API response is supposed to have a status field with values of "active" or "inactive", the schema will flag "enabled" as invalid.

If you're not using JSON Schema yet, read our JSON Schema explainedguide for a practical introduction. It's one of the most underused tools in a developer's toolkit.

Best VS Code Extensions for JSON Validation

The built-in features cover most use cases. But if you work with JSON all day, these extensions take you further.

Prettier

Prettier is an opinionated code formatter that supports JSON. Install the Prettier - Code formatter extension and it replaces the built-in formatter with more consistent output. It handles edge cases the built-in formatter misses and ensures your JSON style matches the rest of your codebase.

JSON Tools

The JSON Tools extension adds two commands: JSON Prettify and JSON Minify. It sounds simple, but it handles large files better than the built-in formatter. If you regularly work with JSON responses that are hundreds of thousands of lines, this extension is worth installing.

ESLint

If you use the eslint-plugin-jsonc package, ESLint can lint your JSON files using customizable rules. This goes beyond syntax validation - you can enforce naming conventions, ban certain keys, require specific structures, and integrate JSON linting into your CI pipeline.

Sort JSON Objects

Not a validator, but a lifesaver for maintainability. The Sort JSON objects extension alphabetically sorts keys in your JSON files. Consistent key ordering makes diffs cleaner and code reviews faster - which indirectly prevents errors from slipping through.

When VS Code Isn't Enough

VS Code is excellent for JSON validation. But it's not always the right tool. Here are the situations where you need something else.

Large Files

VS Code starts to struggle with JSON files over 10-20 MB. The editor slows down, syntax highlighting lags, and the validator can choke. If you're working with database dumps, API logs, or analytics exports, you need a tool built for large file handling.

Quick Checks Without Opening an IDE

Sometimes you just need to paste a JSON snippet and check if it's valid. Maybe you're on a colleague's machine, on a server via SSH, or in the middle of a Slack conversation. Opening VS Code, creating a file, pasting the content, then checking the Problems panel - that's too many steps for a five-second task.

Sharing With Non-Developers

Your product manager sends you a JSON payload that isn't working. You could tell them to install VS Code. Or you could send them a link to an online validator where they paste the JSON and see the error immediately. No installation, no setup, no learning curve.

API Response Debugging

When you're testing API endpoints and copying responses from curl, Postman, or browser dev tools, an online tool is often faster. Paste, validate, format - all in one step, right in your browser.

Why an Online JSON Validator Complements VS Code

The best workflow uses both. VS Code is your primary editor for JSON files in your project - configs, fixtures, data files. It validates as you type, formats on save, and enforces schemas automatically.

An online validator handles everything else. The one-off checks. The large files that would slow your editor. The quick pastes from Stack Overflow. The debugging sessions where you need instant feedback without file management overhead.

This is not an either-or choice. Think of it like having a kitchen knife and a Swiss Army knife. You use the kitchen knife at home where it belongs. But the Swiss Army knife goes everywhere with you because you never know when you'll need it.

JSON Prettifier validates, formats, and highlights errors in real time - no installation, no sign-up, no file size limits getting in your way. Keep VS Code as your daily driver and bookmark jsonprettifier.com for everything else.

Validate JSON Instantly - No IDE Required

Paste your JSON and get instant validation with clear error messages. Works with files of any size, right in your browser.

Open JSON Prettifier