{"id":37626671,"url":"https://github.com/hanzhichao/json2schema","last_synced_at":"2026-01-16T10:49:54.735Z","repository":{"id":62572789,"uuid":"310167073","full_name":"hanzhichao/json2schema","owner":"hanzhichao","description":"JSON to JSONSchema","archived":false,"fork":false,"pushed_at":"2023-06-22T06:26:05.000Z","size":26,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-11-12T01:41:11.578Z","etag":null,"topics":["json","jsonschema","python"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/json2schema/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/hanzhichao.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-05T02:14:32.000Z","updated_at":"2024-08-16T02:05:16.000Z","dependencies_parsed_at":"2022-11-04T00:23:51.169Z","dependency_job_id":null,"html_url":"https://github.com/hanzhichao/json2schema","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/hanzhichao/json2schema","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhichao%2Fjson2schema","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhichao%2Fjson2schema/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhichao%2Fjson2schema/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhichao%2Fjson2schema/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/hanzhichao","download_url":"https://codeload.github.com/hanzhichao/json2schema/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/hanzhichao%2Fjson2schema/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28478071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T06:30:42.265Z","status":"ssl_error","status_checked_at":"2026-01-16T06:30:16.248Z","response_time":107,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["json","jsonschema","python"],"created_at":"2026-01-16T10:49:52.786Z","updated_at":"2026-01-16T10:49:54.724Z","avatar_url":"https://github.com/hanzhichao.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json2schema\n\nGet (Guess) jsonschema from one json sample\n\n![example workflow](https://github.com/hanzhichao/json2schema/actions/workflows/python-app.yml/badge.svg)\n[![](https://travis-ci.org/hanzhichao/json2schema.svg?branch=main)](https://travis-ci.org/hanzhichao/json2schema)\n![Languate - Python](https://img.shields.io/badge/language-python-blue.svg)\n![PyPI - License](https://img.shields.io/pypi/l/json2schema)\n![PyPI](https://img.shields.io/pypi/v/jsonpath)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/json2schema)\n\n\n\n\n## Features\n\n- json to jsonschema\n\n## Install\n\n```\n$ pip install json2schema\n```\n\n## Use\n\n### Simple Use\n\n```python\nfrom json2schema import json2schema\nfrom pprint import pprint\n\ndata = {\n    \"first_name\": \"George\",\n    \"last_name\": \"Washington\",\n    \"birthday\": \"1732-02-22\",\n    \"address\": {\n        \"street_address\": \"3200 Mount Vernon Memorial Highway\",\n        \"city\": \"Mount Vernon\",\n        \"state\": \"Virginia\",\n        \"country\": \"United States\"\n    }\n}\n\nschema = json2schema(data)\npprint(schema)\n\n```\noutput\n\n```shell\n{'$schema': 'http://json-schema.org/schema',\n 'properties': {'address': {'properties': {'city': {'type': 'string'},\n                                           'country': {'type': 'string'},\n                                           'state': {'type': 'string'},\n                                           'street_address': {'type': 'string'}},\n                            'required': ['street_address',\n                                         'city',\n                                         'state',\n                                         'country'],\n                            'type': 'object'},\n                'birthday': {'type': 'string'},\n                'first_name': {'type': 'string'},\n                'last_name': {'type': 'string'}},\n 'required': ['first_name', 'last_name', 'birthday', 'address'],\n 'type': 'object'}\n```\n\n### More arguments\n\nYou can use `required_all=True` to mark all properties or items as required\nwith `schema = json2schema(data, required_all=True)` you will get \n```shell\n{'$schema': 'http://json-schema.org/schema',\n 'properties': {'address': {'properties': {'city': {'type': 'string'},\n                                           'country': {'type': 'string'},\n                                           'state': {'type': 'string'},\n                                           'street_address': {'type': 'string'}},\n                            'required': ['street_address',\n                                         'city',\n                                         'state',\n                                         'country'],\n                            'type': 'object'},\n                'birthday': {'type': 'string'},\n                'first_name': {'type': 'string'},\n                'last_name': {'type': 'string'}},\n 'required': ['first_name', 'last_name', 'birthday', 'address'],\n 'type': 'object'}\n```\nor use `check_value=True` to mark all value exact the same with the sample data\nwith `schema = json2schema(data, check_value=True)`, you will get\n```shell\n{'$schema': 'http://json-schema.org/schema',\n 'properties': {'address': {'properties': {'city': {'pattern': '^Mount Vernon$',\n                                                    'type': 'string'},\n                                           'country': {'pattern': '^United '\n                                                                  'States$',\n                                                       'type': 'string'},\n                                           'state': {'pattern': '^Virginia$',\n                                                     'type': 'string'},\n                                           'street_address': {'pattern': '^3200 '\n                                                                         'Mount '\n                                                                         'Vernon '\n                                                                         'Memorial '\n                                                                         'Highway$',\n                                                              'type': 'string'}},\n                            'required': ['street_address',\n                                         'city',\n                                         'state',\n                                         'country'],\n                            'type': 'object'},\n                'birthday': {'pattern': '^1732-02-22$', 'type': 'string'},\n                'first_name': {'pattern': '^George$', 'type': 'string'},\n                'last_name': {'pattern': '^Washington$', 'type': 'string'}},\n 'required': ['first_name', 'last_name', 'birthday', 'address'],\n 'type': 'object'}\n ```\n\n## TODO:\n- [ ] get jsonschema with multiple samples\n- [ ] more args for json2schema","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhichao%2Fjson2schema","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhanzhichao%2Fjson2schema","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhanzhichao%2Fjson2schema/lists"}