The JSON Schema Generator tool uses a Wizard to create a compliant JSON Schema by inferring its structure from a sample JSON document. Configuration options control the rules used when inferring the schemas structure.
A possible roundabout way of getting your XSD is to start with a json doc (not the jsonschema) that's pretty complete and conformant to your jsonschema, use any of a multitude of json to xml converters, and convert your xml to xsd (one such tool here).
Summarising the other answers, here are the JSON schema generators proposed so far:
Online:
Python:
NodeJS:
Ruby:
You might be looking for this:
http://www.jsonschema.net
It is an online tool that can automatically generate JSON schema from JSON string. And you can edit the schema easily.
GenSON (PyPI | Github) is a JSON Schema generator that can generate a single schema from multiple objects. You can also merge schemas with it. It is written in Python and comes with a CLI tool.
(Full disclosure: I'm the author.)
Seeing that this question is getting quite some upvotes, I add new information (I am not sure if this is new, but I couldn't find it at the time)
After several months, the best answer I have is my simple tool. It is raw but functional.
What I want is something similar to this. The JSON data can provide a skeleton for the JSON schema. I have not implemented it yet, but it should be possible to give an existing JSON schema as basis, so that the existing JSON schema plus JSON data can generate an updated JSON schema. If no such schema is given as input, completely default values are taken.
This would be very useful in iterative development: the first time the tool is run, the JSON schema is dummy, but it can be refined automatically according to the evolution of the data.
There's a python tool to generate JSON Schema for a given JSON: https://github.com/perenecabuto/json_schema_generator
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With