Back to Blog

5 Ways to Validate JSON Before Deploying

December 3, 2025·7 min read
jsonvalidationdevops

Catch JSON errors before they break production. Here are 5 validation techniques every developer should know.

It was 2 AM when the Slack alerts started firing. The checkout flow was completely broken. Customers were seeing a blank white page instead of their cart.

The culprit? A single missing comma in a JSON configuration file that had been deployed an hour earlier. The developer had manually edited the file, eyeballed it, and pushed it to production. The JSON parser choked, the config didn't load, and the entire feature failed.

This is a true story. And it's entirely preventable.

Here are five ways to validate your JSON before it has a chance to ruin your weekend.

1. Basic Syntax Validation

The first line of defense is simple syntax validation. Is this valid JSON? Can it be parsed at all?

Invalid JSON is surprisingly easy to create:

{
  "name": "test"
  "value": 123
}

Spot the error? There's no comma after "test". This will cause a parse error in any JSON parser. But when you're editing a large file at the end of a long day, it's easy to miss.

The fix is simple: run your JSON through a validator before committing. Our JSON Validator will pinpoint the exact line and character where the syntax breaks.

This takes five seconds and can save you hours of debugging. Make it a habit.

2. Schema Validation

Syntax validation only tells you if the JSON is parseable. It doesn't tell you if it's correct.

Consider this:

{
  "user": {
    "name": "John",
    "email": "not-an-email",
    "age": "twenty-five"
  }
}

This is valid JSON. It will parse without errors. But it's still wrong: the email isn't a valid email, and age should be a number, not a string.

This is where JSON Schema comes in. A schema defines the structure and constraints your JSON must follow:

{
  "type": "object",
  "required": ["user"],
  "properties": {
    "user": {
      "type": "object",
      "required": ["name", "email", "age"],
      "properties": {
        "name": { "type": "string", "minLength": 1 },
        "email": { "type": "string", "format": "email" },
        "age": { "type": "integer", "minimum": 0 }
      }
    }
  }
}

With this schema, the invalid data above would be rejected:

  • email doesn't match the email format
  • age is a string, not an integer

Use our JSON Schema Validator to validate your data against a schema. If you don't have a schema yet, you can generate one from existing valid JSON using our JSON to Schema Generator.

3. Diff Before Deploying

You're about to deploy a configuration change. How do you know exactly what changed?

Looking at the raw file is error-prone. Git diffs help, but they're line-based and don't understand JSON structure. Adding a key at the end might look like you changed every line in the object (because all the commas shifted).

A JSON-aware diff tool is what you need:

// Before
{
  "timeout": 30,
  "retries": 3
}

// After
{
  "timeout": 60,
  "retries": 3,
  "debug": true
}

A smart diff will show you:

  • ✏️ timeout changed from 30 to 60
  • debug was added with value true
  • retries unchanged

Our JSON Diff tool does exactly this. Paste two JSON objects, and it highlights additions (green), deletions (red), and modifications (yellow). Way easier than squinting at a git diff.

4. Format for Readability

Minified JSON saves bytes, but it's impossible to review:

{"server":{"host":"localhost","port":3000,"ssl":{"enabled":true,"cert":"/path/to/cert"}},"database":{"url":"postgres://localhost/db","pool":10}}

Can you spot if there's an error in there? What about if something looks off?

Now with proper formatting:

{
  "server": {
    "host": "localhost",
    "port": 3000,
    "ssl": {
      "enabled": true,
      "cert": "/path/to/cert"
    }
  },
  "database": {
    "url": "postgres://localhost/db",
    "pool": 10
  }
}

Much easier to read, review, and spot issues.

Use our JSON Formatter to prettify JSON before code review. It also validates syntax, so you get two checks in one.

Pro tip: Most code editors can format JSON automatically. In VS Code, select the JSON and press Shift+Alt+F (Windows) or Shift+Option+F (Mac).

5. Automate in CI/CD

Manual validation is good. Automated validation is better.

Add JSON validation to your CI pipeline so broken JSON can never make it to production:

# GitHub Actions example
name: Validate JSON Configs
on: [push, pull_request]

jobs:
  validate:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v3
      
      - name: Validate JSON files
        run: |
          for file in config/*.json; do
            echo "Validating $file..."
            python -m json.tool "$file" > /dev/null
            if [ $? -ne 0 ]; then
              echo "❌ Invalid JSON: $file"
              exit 1
            fi
            echo "✅ Valid"
          done

This simple script checks every JSON file in your config/ directory. If any file is invalid, the pipeline fails and the deploy is blocked.

For schema validation in CI, you can use tools like ajv-cli:

- name: Install ajv-cli
  run: npm install -g ajv-cli

- name: Validate against schema
  run: ajv validate -s schema.json -d config.json

Putting It All Together

Here's my recommended validation workflow:

  1. During development: Use your editor's built-in formatter to catch syntax errors as you type

  2. Before committing: Run the JSON through a validator and formatter

  3. During code review: Use JSON diff to see exactly what changed

  4. In CI/CD: Automated syntax and schema validation

  5. Before deploying: One final manual check of the diff

Is this overkill? Maybe. But I've never been woken up at 2 AM because of a JSON error since adopting this workflow. That's worth a few extra minutes of validation.

Tools for Your Toolkit

Here are the tools that make this workflow easy:

All of these run in your browser with no data sent to any server. Paste, validate, done.

Don't let a typo break production. Validate your JSON.

Tools mentioned in this article:

Related Tools

More Articles