JSON To Sarcastic
Convert JSON sample data into Sarcastic runtime type validators for JavaScript applications.
Generate Sarcastic validators from JSON payloads
JavaScript applications often need runtime type checks for API responses, webhook payloads,
and configuration objects. The Sarcastic library provides expressive validators, but writing
nested is.shape definitions by hand is tedious. This generator inspects your
JSON sample and emits Sarcastic validator code you can paste into a project.
What this tool does
Paste JSON in the input panel. The converter walks nested objects and arrays, infers
primitive and composite shapes, and outputs Sarcastic validator definitions with
is.arrayOf helpers for list fields. You can customize the root validator name
before copying the result.
Configuration options
- Validator Name: Rename the root validator constant generated from your JSON sample.
Common use cases
- Bootstrap runtime validation for fetch responses in Node or browser apps.
- Create starter validators before wiring assertion helpers.
- Document expected payload shapes for frontend and backend teams.
- Compare inferred validators against JSON Schema or OpenAPI contracts.
Related tools
Need TypeScript codecs instead? Try the JSON to io-ts or JSON Schema to Zod. For React component validation, use the JSON to PropTypes tool.
Frequently Asked Questions
Does my JSON leave the browser?
No. Conversion runs entirely in your browser. Your JSON is never uploaded to a server, which makes the tool safe for internal API samples and production-like fixtures.
Do I need to install sarcastic in my project?
Yes. The generated output imports sarcastic. Install it with your
package manager, then use the validator with is(value, ValidatorName)
in your runtime checks.
Can I rename the root validator?
Yes. Use the Validator Name field to control the exported constant name. Nested helper validators keep generated names based on object keys in your JSON sample.
How is Sarcastic different from io-ts or Zod?
Sarcastic focuses on lightweight runtime assertions with a small API surface. io-ts and Zod provide richer codec ecosystems for TypeScript projects. Choose based on your stack, bundle size goals, and typing workflow.