โ† Back to blog

How to Validate JSON Before Production

Broken JSON takes down deploys and APIs. Learn a practical validation workflow with examples from CI, webhooks, and config files.

Invalid JSON has a talent for arriving five minutes before a release. A trailing comma in settings.json, a single-quoted key in an API fixture, or a truncated copy from a log viewer - and your pipeline stops, your webhook handler crashes, or your mobile app cannot parse config. Validating JSON before production is cheap insurance.

This guide covers a practical workflow, real failure stories, and free tools that run in your browser.

Syntax vs schema validation

Two layers matter:

  1. Syntax - Is the text valid JSON at all? (JSON Validator)
  2. Schema - Does the document match an expected shape? (JSON Schema Validator)

Syntax fails on commas, quotes, and brackets. Schema fails when required fields are missing or types are wrong ("age": "thirty" instead of 30).

Always fix syntax first. Formatting with JSON Formatter only works on valid input.

Real production scenarios

Webhook payloads

Scenario: Stripe, GitHub, or Shopify sends POST bodies your service parses with JSON.parse. A vendor test event includes NaN or unquoted keys in a sandbox (rare but memorable).

Workflow: Save failing payload to a file. Validate syntax. If valid, validate against your OpenAPI or JSON Schema contract before patching the handler.

CI config and IaC

Scenario: Terraform plan JSON export, CloudFormation parameters, or a custom CI matrix file breaks the build.

Workflow: Paste into validator, fix line/column from the error, commit, re-run pipeline. Faster than grep-ing for trailing commas.

Mobile app remote config

Scenario: Marketing updates Firebase remote config JSON from a spreadsheet export. App crashes on launch in staging.

Workflow: Schema-validate required keys (min_app_version, feature_flags) before publish. Syntax check catches paste errors; schema catches missing flags.

Log pipeline debugging

Scenario: Log shipper expects JSON lines; one service prints pretty-printed multi-line JSON, breaking NDJSON consumers.

Workflow: Validate each line independently. Multi-line pretty JSON is valid JSON as a document but invalid as NDJSON - different tool, same discipline.

Step-by-step validation checklist

  1. Copy the exact bytes - no ellipses, no "..." truncation
  2. Run JSON Validator - read first error line/column
  3. Fix and re-validate until clean
  4. Optional: JSON Schema Validator against contract
  5. Format for review with JSON Formatter before PR
  6. Store fixtures in version control for regression tests

Common errors and fixes

ErrorTypical causeFix
Unexpected tokenTrailing comma, commentsRemove comma; strip // comments (not valid JSON)
Unexpected endTruncated pasteCopy full payload
Expected property nameSingle-quoted keysUse double quotes
NaN / InfinityJavaScript object literalReplace with null or strings

Remember: JSON is not JavaScript. undefined, functions, and unquoted keys are invalid.

Automating beyond the browser

Browser tools excel for ad-hoc debugging. For pipelines, add:

  • jq empty file.json in shell scripts
  • ajv validate -s schema.json -d data.json in CI
  • Unit tests that load golden fixtures

Utilitoo complements automation - engineers still paste one-off payloads during incidents.

Privacy

Webhook bodies contain PII and secrets. Utilitoo validates locally in the browser - payloads are not uploaded for validation. Rotate credentials if they were ever exposed in a shared channel.

Putting it into team practice

Add a note to your runbook: "paste failing payload into validator before escalating." New hires learn faster when the checklist names a concrete tool. Keep golden invalid fixtures (trailing-comma.json, truncated.json) in the repo so CI and humans share the same examples.

Summary

Validate JSON syntax before every risky deploy, schema when contracts matter, and format for human review last. Real teams catch errors in webhooks, CI configs, and remote settings this way. Start with JSON Validator, escalate to JSON Schema Validator when structure is part of the contract.

Try these tools