JSON to Sarcastic Schema Converter
Paste a JSON sample to instantly generate a matching Sarcastic runtime type-checking schema, with nested shapes, arrays, and optional/nullable fields inferred automatically. Free online developer tool.
Paste JSON
Sarcastic Schema
Sarcastic schema definition will appear here...
Free JSON to Sarcastic Schema Converter
Paste a JSON sample to instantly generate a matching runtime type-checking schema using Sarcastic'sshape/arrayOf/optional/maybe API. Nested objects become nested shape({...}) calls, arrays become arrayOf(T), and optional or nullable fields are wrapped accordingly.
How to Use It
Paste any JSON object into the input box, or click "Load Example" to see a sample run. The converter parses your JSON, infers a validator for every field, and generates a singleconst Root = shape({...}); declaration with nested objects described inline.
Example
Given {"name": "Ann", "tags": ["a","b"], "address": {"city": "NYC", "zip": null}}, the tool generates name: string, tags: arrayOf(string), andaddress: shape({ city: string, zip: maybe(string) }) for the nested object, sincezip was observed as null.
Common Use Cases
- Bootstrapping runtime validators for an API response before writing hand-rolled checks.
- Getting a quick starting schema to refine for input validation in a Node.js service.
- Documenting the exact optional/nullable shape of a JSON payload for teammates.
- Speeding up onboarding of a new endpoint into an existing Sarcastic-based validation layer.
FAQs
What API convention does the generated output follow?
The output follows Sarcastic's documented shape/arrayOf/optional/maybe API convention, with bare string, number, andboolean validators for primitives (rather than function calls). If your installed version of Sarcastic differs slightly, adjust the generated names to match.
How are optional and nullable fields combined?
A field that was ever null is wrapped in maybe(T), and a field that was missing from at least one sample is wrapped in optional(T). A field that's both gets wrapped in optional(maybe(T)).
Is my JSON uploaded anywhere?
No — parsing and schema generation happen entirely client-side in your browser. Nothing you paste is sent to a server.
