Menu

Post image 1
Post image 2
1 / 2
0

How to convert a JSON sample to a Valibot schema (and the 3 ways the algorithm diverges from Zod)

DEV Community·JSON to TS·23 days ago
#BCHH50As
Reading 0:00
15s threshold

When you sit down to build runtime validation for an API boundary in TypeScript, the first half-hour goes into picking a library. Zod is the default. Valibot is the 2026 upstart that you start hearing about once your bundle size gets audited — same expressive surface, but pipe-based composition and per-primitive tree-shaking instead of a monolithic chainable class. Both libraries answer the same question: given an unknown JSON value at runtime, prove its shape. And both expect you to write the schema by hand. That's the part nobody likes. So I wrote a converter — paste a JSON sample, get back a Valibot schema you can tighten by hand. The tool is here, free, no signup, runs entirely in the browser: json-to-ts-app.netlify.app . Internally the Valibot emitter is a sister function to the Zod emitter I wrote up last week . Same shape walk, same naming/uniquify logic, same children-first ordering.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More