json-safety
What it does
This skill reviews code that reads JSON from APIs, browser storage or users, and makes sure parsing errors are handled. It is for developers who handle external data.
When to use it
- ✓When your app crashes after receiving a malformed API response.
- ✓When a browser storage value is corrupted and breaks the page.
- ✓When your code uses parsed data without checking its shape.
Skill link
https://github.com/thedaviddias/Front-End-Checklist/blob/main/skills/json-safety/SKILL.mdCopy it and paste it into your AI (Claude, ChatGPT or Cursor), asking it to follow the instructions.
How to use
The easiest way: copy the message and paste it into your AI. It reads the skill and follows the instructions.
Ready-to-paste message
For Claude Code, Codex or Cursor: run it in your project folder and the skill gets installed.
Download the SKILL.md and drop it into your agent’s skills folder.
Example of what to ask your AI
“Can you make my JSON parsing safe in case the data is malformed?”
5 new skills a week. 1 minute to read.
How it works
The agent finds JSON.parse calls and checks that each one is wrapped in error handling and that the result is validated before use. It can suggest a schema validation library for external data.
Technical content (original SKILL.md)
Original text by the author, straight from GitHub.
Parse JSON safely with error handling
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/rules/javascript/json-safety
FAQ
What happens when JSON parsing fails?
The skill says JSON.parse throws a syntax error, which will crash the app if it is not caught.
Why validate parsed data?
The skill says it catches unexpected shapes at the point of parsing, instead of causing errors later.
Which libraries are mentioned?
The skill mentions Zod and Valibot as type-safe validators for external data.
Details
Original description by the author
Use when reviewing scripts, client components, bundles, or runtime behavior related to Parse JSON safely with error handling. Inspect both source code and the browser execution path so fixes target the real bottleneck or bug.
Popularity
- GitHub stars
- 75k
- Ranking position
- #2907
- License
- MIT
- Updated
- 10/31/2026
Comments
- …
More skills from this repository
frontendchecklist
75kChecks frontend code and live pages against 380+ rules for accessibility, speed, SEO and security, using a command-line tool.
frontend-checklist-global
75kAudits a frontend project against all 386 Front-End Checklist rules, and gives a specific fix for each issue found.
404-page
75kChecks that your missing-page screen offers helpful links and returns a real 404 status, to help lost visitors find their way.
about-page
75kReviews whether your site has a clear About page that explains who runs it, to build trust with visitors and search engines.
Similar skills
diffs
394kLets your agent produce a real, shareable diff of edits as a viewer link or image file, instead of a hand-written summary.
coding-agent
394kHelps your agent hand a larger coding job to Codex, Claude Code, or OpenCode as a background worker, then check on its progress.
gh-issues
394kHelps your agent find GitHub issues, pick the ones to work on, and open pull requests with fixes, including follow-up on review comments.