JSON to Valibot
Paste or drop your data here, or open a file.
New to Bracely?
Everything stays in your browser.
Output appears here
Paste or open your data in the input box. It never leaves your browser.
JSON to Valibot
Paste a JSON sample, such as an API response, and Bracely writes Valibot schemas and TypeScript types for it. Each object becomes a v.object() schema with an inferred output type, written with Valibot's small functions so a bundler keeps only the ones you use.
Example: an editor's settings, validated in the browser
A settings object kept in local storage. Each object becomes a v.object() schema and a whole number becomes v.pipe(v.number(), v.integer()), so a hand-edited value like 14.5 is caught:
Input
{
"theme": "dark",
"fontSize": 14,
"autosave": true,
"shortcuts": {
"save": "Ctrl+S",
"search": "Ctrl+K"
},
"recentFiles": [
"orders.json",
"users.csv"
]
}Output
import * as v from "valibot";
export const ShortcutsSchema = v.object({
save: v.string(),
search: v.string(),
});
export type Shortcuts = v.InferOutput<typeof ShortcutsSchema>;
export const SettingsSchema = v.object({
theme: v.string(),
fontSize: v.pipe(v.number(), v.integer()),
autosave: v.boolean(),
shortcuts: ShortcutsSchema,
recentFiles: v.array(v.string()),
});
export type Settings = v.InferOutput<typeof SettingsSchema>;
How do I use the JSON to Valibot?
- Paste a JSON sample.
- Set the root type name, for example Order.
- Copy the Valibot code into your project.
What does the JSON to Valibot do?
- v.object schemas in dependency order
- v.InferOutput types exported for each
- v.optional and v.pipe(v.number(), v.integer()) from your data
- Nested objects become their own named types
- 20 other languages from the same sample, including TypeScript
When to use the JSON to Valibot
Valibot validates data like Zod but is built from small separate functions, so a bundler keeps only the ones your schemas use. That matters in browser code, edge functions and widgets where every kilobyte counts. Paste the JSON you need to check, such as settings from local storage or an API response, and copy schemas for it.
Each object becomes a v.object() schema, written in dependency order so each is defined before it's used, with v.InferOutput giving its TypeScript type. Whole numbers become v.pipe(v.number(), v.integer()), so 14.5 fails where 14 is expected. Fields missing from some items are v.optional(), and values that are sometimes null are v.nullable().
Frequently asked questions
- How do I check data with the schema?
- v.parse(SettingsSchema, data) returns the typed value or throws; v.safeParse(SettingsSchema, data) returns a result with success and issues instead, which suits forms and stored data you don't want to crash on.
- Valibot or Zod?
- Both describe the same things. Zod is the most widely used; Valibot is designed for small bundles. Bracely writes either from the same sample: change Language to Zod.
- How does it pick Valibot types?
- From the values in your sample: whole numbers, decimals, text, true/false, arrays and nested objects. When array items disagree, the field is made optional or widened.
- Can I generate other languages?
- Yes. Change Language to any of the others: TypeScript, Go, Python, Pydantic, Java, C#, Kotlin, Swift, Rust, Scala, Ruby, Dart, PHP, Zod, TypeBox, Yup, GraphQL, Protobuf, Prisma and Drizzle.
- Is my data uploaded?
- No. Bracely runs entirely in your browser, so nothing you paste or open leaves your device.
More JSON tools
Bracely has 104 JSON tools in one page. Related ones:
- JSON to Yup
- JSON to Prisma
- JSON to Drizzle
- JSON to Scala
- JSON to Ruby
- JSON Schema builder
- JSON Schema validator
- JSON data dictionary
- OpenAPI from JSON
- JSON to ER diagram
- JSON Schema to TypeScript
- OpenAPI to TypeScript
- GraphQL to TypeScript
- Avro to code
- YAML to JSON
- CSV to JSON
- JSON hash
- Edge-case test data
- HTML formatter
- CSS formatter
- JSON Formatter
- JSON Validator
- JSON Viewer
- JSON Repair
- JSON Diff
- JSON to YAML
- JSON to CSV
- jq Playground
Runs entirely in your browser. Nothing you paste is uploaded. Made by Saurabh Pagrut · About · Privacy policy
Last updated · Version 6.1 · Changelog
Saurabh Pagrut on GitHub · LinkedIn · X · YouTube · Instagram