Parse JSON safely with error handling

SkillWeb & browsing

json-safety is a skill for AI agents that reviews JavaScript code and runtime behavior for unsafe JSON parsing. It checks that JSON.parse() calls are wrapped in error handling and that parsed data is validated before use, so malformed API responses, localStorage values, or user input do not crash the application.

Available today. Use it from your connected AI after setup.

Have an agent environment that supports loading skills, and add the json-safety skill to it.

Then ask your AI: use the Parse JSON safely with error handling skill

What your AI can do with it

  • Find all JSON.parse() calls in a file and check whether each is wrapped in try/catch
  • Check whether parsed data is validated before its properties are accessed
  • Flag JSON.stringify() cases that can return undefined for unserializable values
  • Recommend type-safe parsers such as Zod or Valibot for external data
  • Review scripts, client components, and browser execution paths for violations
  • Explain why JSON.parse throws and when to use schema validation

Getting started

  1. Have an agent environment that supports loading skills, and add the json-safety skill to it.
  2. Open the script, component, or bundle you want reviewed in the context of the agent.
  3. Ask the agent to run the check, fix, explain, or code review instructions for JSON safety.
  4. Apply the suggested try/catch and shape-validation changes, then verify the behavior in the browser.
  5. Consult references/rule.md for full implementation details and framework-specific guidance.

What this skill tells your AI

The instructions your AI receives, as published by thedaviddias/front-end-checklist in skills/json-safety/SKILL.md and read by ahel’s review.

JSON.parse() on invalid input throws a SyntaxError that will crash your application if uncaught. API responses, localStorage values, and user-provided data can all be malformed. Safe parsing with validation catches these errors at the point of parsing, not deep in your application logic when a missing property causes an unexpected error.

Quick Reference

  • JSON.parse() throws a SyntaxError on invalid input — always use try/catch
  • Validate the shape of parsed data before accessing its properties
  • JSON.stringify() can return undefined for values that can't be serialized
  • Use a type-safe parser (Zod, Valibot) for data from external sources

Check

Find all JSON.parse() calls in this file and check whether each one is wrapped in try/catch and whether the result is validated before use.

Fix

Add try/catch error handling to all JSON.parse() calls and add shape validation to protect against unexpected data structures.

Explain

Explain why JSON.parse can throw, what safe JSON parsing looks like, and when to use schema validation libraries.

Code Review

Review scripts, client components, and browser execution paths related to Parse JSON safely with error handling. Flag exact imports, event handlers, runtime side effects, or blocking operations that violate the rule, and state how the change should be verified in the browser.


For full implementation details, code examples, and framework-specific guidance, see references/rule.md.

Rule page: https://frontendchecklist.io/en/rules/javascript/json-safety

Signals

GitHub stars
74k
Forks
7k
Last commit
Aug 2026

Questions

What does json-safety check for?
It checks that every JSON.parse() call is wrapped in try/catch and that parsed data is validated before use, catching SyntaxError crashes and unexpected data shapes at the parsing point.
When should I use this skill?
When reviewing scripts, client components, bundles, or runtime behavior related to parsing JSON safely with error handling, especially for API responses, localStorage values, or user-provided data.
Advanced
Item type
skill
Key
json-safety
Source
github.com/thedaviddias/front-end-checklist