At my workplace we use Zod for a similar sort of thing. It works especially well since some of our untyped data comes from non-JSON sources, e.g. CSV, database queries.
Interesting, but it isn’t clear from the Readme how it’s doing the same thing? The section on type inference doesn’t seem to mean the same thing (https://github.com/colinhacks/zod#type-inference).
The purpose of this library is more oriented around exploring existing data rather than being used to define schemas for use in your application development.
Maybe I’m misunderstanding zod though.
While I’m sure there are more libraries that do this kind of thing, they’re kind of hard to find! The JSON Schema project lists a few of them: https://json-schema.org/implementations.html#from-data.
Surely you’ve seen Quicktype on that list, right? It’s one of my go-to options!
I didn’t actually find the json-schema list until after I wrote this library. But yes it looks very good!
String or number or number or number?
Oops. That’s a screenshot from an earlier version with that bug. I’ll have to fix that. :) Thanks
The screenshot is fixed now. :) Thanks!