{"id":18792074,"url":"https://github.com/tgreyuk/json-schemify","last_synced_at":"2026-05-08T13:08:28.441Z","repository":{"id":48080361,"uuid":"153027444","full_name":"tgreyuk/json-schemify","owner":"tgreyuk","description":"A tool that converts any JSON structure to a valid JSON Schema object.","archived":false,"fork":false,"pushed_at":"2021-08-08T12:28:50.000Z","size":794,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-12-29T15:15:00.230Z","etag":null,"topics":["json","json-schema","schema"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/tgreyuk.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2018-10-14T23:14:07.000Z","updated_at":"2022-10-03T06:37:11.000Z","dependencies_parsed_at":"2022-08-12T18:10:39.274Z","dependency_job_id":null,"html_url":"https://github.com/tgreyuk/json-schemify","commit_stats":null,"previous_names":["tgreyjs/json-schemify"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgreyuk%2Fjson-schemify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgreyuk%2Fjson-schemify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgreyuk%2Fjson-schemify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tgreyuk%2Fjson-schemify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tgreyuk","download_url":"https://codeload.github.com/tgreyuk/json-schemify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239718329,"owners_count":19685722,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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","json-schema","schema"],"created_at":"2024-11-07T21:18:16.483Z","updated_at":"2025-12-28T01:30:12.357Z","avatar_url":"https://github.com/tgreyuk.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# json-schemify\r\n\r\n![json-schemify](logos.png)\r\n\r\nConverts any JSON structure to a valid [JSON Schema](http://json-schema.org/) object.\r\n\r\n[![npm](https://img.shields.io/npm/v/json-schemify.svg)](https://www.npmjs.com/package/json-schemify)\r\n![CI](https://github.com/tgreyuk/json-schemify/actions/workflows/ci.yml/badge.svg?branch=master)\r\n\r\n## Getting started\r\n\r\n### Installation\r\n\r\n```js\r\nnpm install json-schemify --save-dev\r\n```\r\n\r\n### Usage\r\n\r\n```js\r\nconst { writeSchema } = require('json-schemify');\r\n```\r\n\r\n## API\r\n\r\n### writeSchema\r\n\r\n**writeSchema**(`json`, `filepath`, `options`)\r\n\r\nWrites to a JSON schema output file.\r\n\r\n```js\r\nconst json= {\r\n  firstName: 'John',\r\n  lastName: 'Doe',\r\n  age: 21,\r\n}\r\n\r\nwriteSchema(json, 'schema.json');\r\n```\r\n\r\n#### Params\r\n\r\n##### `json`\r\n\r\nAny valid JSON.\r\n\r\n##### `filepath`\r\n\r\nThe filepath of the file to write.\r\n\r\n##### `options`\r\n\r\n| Option       | Description                      |\r\n| ------------ | -------------------------------- |\r\n| id?          | The \\$id property of the schema  |\r\n| title?       | The title property of the schema |\r\n| prettyPrint? | Pretty print Json  output        |\r\n\r\n___\r\n\r\n### schemify\r\n\r\n**schemify**(`json`, `options`)\r\n\r\nReturns the JSON schema object (rather than writing to file).\r\n\r\n\r\n```js\r\nconst json= {\r\n  firstName: 'John',\r\n  lastName: 'Doe',\r\n  age: 21,\r\n}\r\n\r\nconst schema = schemify(json);\r\n\r\n// do something with schema\r\nconsole.log(schema);\r\n```\r\n\r\n#### Params\r\n\r\n##### `json`\r\n\r\nAny valid JSON.\r\n\r\n##### `options`\r\n\r\n| Option | Description                      |\r\n| ------ | -------------------------------- |\r\n| id?    | The \\$id property of the schema  |\r\n| title? | The title property of the schema |\r\n\r\n#### Returns\r\n\r\nA valid JSON Schema Object (draft-07)\r\n\r\n## Example\r\n\r\nThis example returns a basic schema.\r\n\r\n### Json\r\n\r\n```js\r\n{\r\n  firstName: 'John',\r\n  lastName: 'Doe',\r\n  age: 21,\r\n};\r\n```\r\n\r\n### Result\r\n\r\n```js\r\n{\r\n  \"$schema\": \"http://json-schema.org/draft-07/schema#\",\r\n  \"type\": \"object\",\r\n  \"properties\": {\r\n    \"firstName\": { \"type\": \"string\" },\r\n    \"lastName\": { \"type\": \"string\" },\r\n    \"age\": { \"type\": \"integer\" }\r\n  }\r\n}\r\n```\r\n\r\n\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgreyuk%2Fjson-schemify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftgreyuk%2Fjson-schemify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftgreyuk%2Fjson-schemify/lists"}