{"id":7279944,"url":"https://github.com/glideapps/quicktype","last_synced_at":"2025-05-13T15:03:09.845Z","repository":{"id":37451038,"uuid":"97062850","full_name":"glideapps/quicktype","owner":"glideapps","description":"Generate types and converters from JSON, Schema, and GraphQL","archived":false,"fork":false,"pushed_at":"2025-05-05T04:34:26.000Z","size":19793,"stargazers_count":12951,"open_issues_count":517,"forks_count":1123,"subscribers_count":95,"default_branch":"master","last_synced_at":"2025-05-06T14:58:48.179Z","etag":null,"topics":["cplusplus","csharp","elm","golang","graphql","java","json","json-schema","kotlin","objective-c","rust","swift","typescript"],"latest_commit_sha":null,"homepage":"https://app.quicktype.io","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/glideapps.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":"quicktype","patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"otechie":null,"lfx_crowdfunding":null,"custom":null}},"created_at":"2017-07-13T00:22:50.000Z","updated_at":"2025-05-06T06:47:27.000Z","dependencies_parsed_at":"2024-01-31T08:05:11.597Z","dependency_job_id":"ccb0f41d-8a06-4d93-9c29-88684f3b16e8","html_url":"https://github.com/glideapps/quicktype","commit_stats":{"total_commits":3059,"total_committers":194,"mean_commits":"15.768041237113403","dds":"0.47531873161163773","last_synced_commit":"29bb8160660a7daa2a837ac0cb1e92f99729ad8e"},"previous_names":["quicktype/quicktype"],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fquicktype","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fquicktype/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fquicktype/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/glideapps%2Fquicktype/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/glideapps","download_url":"https://codeload.github.com/glideapps/quicktype/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252922341,"owners_count":21825639,"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":["cplusplus","csharp","elm","golang","graphql","java","json","json-schema","kotlin","objective-c","rust","swift","typescript"],"created_at":"2024-04-03T06:47:17.985Z","updated_at":"2025-05-13T15:03:09.824Z","avatar_url":"https://github.com/glideapps.png","language":"TypeScript","readme":"![](https://raw.githubusercontent.com/quicktype/quicktype/master/media/quicktype-logo.svg?sanitize=true)\n\n[![npm version](https://badge.fury.io/js/quicktype.svg)](https://badge.fury.io/js/quicktype)\n![Build status](https://github.com/quicktype/quicktype/actions/workflows/master.yaml/badge.svg)\n\n`quicktype` generates strongly-typed models and serializers from JSON, JSON Schema, TypeScript, and [GraphQL queries](https://blog.quicktype.io/graphql-with-quicktype/), making it a breeze to work with JSON type-safely in many programming languages.\n\n-   [Try `quicktype` in your browser](https://app.quicktype.io).\n-   Read ['A first look at quicktype'](http://blog.quicktype.io/first-look/) for more introduction.\n-   If you have any questions, check out the [FAQ](FAQ.md) first.\n\n### Supported Inputs\n\n| JSON | JSON API URLs | [JSON Schema](https://app.quicktype.io/#s=coordinate) |\n| ---- | ------------- | ----------------------------------------------------- |\n\n| TypeScript | GraphQL queries |\n| ---------- | --------------- |\n\n### Target Languages\n\n| [Ruby](https://app.quicktype.io/#l=ruby) | [JavaScript](https://app.quicktype.io/#l=js) | [Flow](https://app.quicktype.io/#l=flow) | [Rust](https://app.quicktype.io/#l=rust) | [Kotlin](https://app.quicktype.io/#l=kotlin) |\n| ---------------------------------------- | -------------------------------------------- | ---------------------------------------- | ---------------------------------------- | -------------------------------------------- |\n\n| [Dart](https://app.quicktype.io/#l=dart) | [Python](https://app.quicktype.io/#l=python) | [C#](https://app.quicktype.io/#l=cs) | [Go](https://app.quicktype.io/#l=go) | [C++](https://app.quicktype.io/#l=cpp) |\n| ---------------------------------------- | -------------------------------------------- | ------------------------------------ | ------------------------------------ | -------------------------------------- |\n\n| [Java](https://app.quicktype.io/#l=java) | [Scala](https://app.quicktype.io/#l=scala3) | [TypeScript](https://app.quicktype.io/#l=ts) | [Swift](https://app.quicktype.io/#l=swift) | [Objective-C](https://app.quicktype.io/#l=objc) | [Elm](https://app.quicktype.io/#l=elm) |\n| ---------------------------------------- | ------------------------------------------- | -------------------------------------------- | ------------------------------------------ | ----------------------------------------------- | -------------------------------------- |\n\n| [JSON Schema](https://app.quicktype.io/#l=schema) | [Pike](https://app.quicktype.io/#l=pike) | [Prop-Types](https://app.quicktype.io/#l=javascript-prop-types) | [Haskell](https://app.quicktype.io/#l=haskell) | [PHP](https://app.quicktype.io/#l=php) |\n| ------------------------------------------------- | ---------------------------------------- | --------------------------------------------------------------- | ---------------------------------------------- | -------------------------------------- |\n\n_Missing your favorite language? Please implement it!_\n\n## Installation\n\nThere are many ways to use `quicktype`. [app.quicktype.io](https://app.quicktype.io) is the most powerful and complete UI. The web app also works offline and doesn't send your sample data over the Internet, so paste away!\n\nFor the best CLI, we recommend installing `quicktype` globally via `npm`:\n\n```bash\nnpm install -g quicktype\n```\n\n## Using `quicktype`\n\n```bash\n# Run quicktype without arguments for help and options\nquicktype\n\n# quicktype a simple JSON object in C#\necho '{ \"name\": \"David\" }' | quicktype -l csharp\n\n# quicktype a top-level array and save as Go source\necho '[1, 2, 3]' | quicktype -o ints.go\n\n# quicktype a sample JSON file in Swift\nquicktype person.json -o Person.swift\n\n# A verbose way to do the same thing\nquicktype \\\n  --src person.json \\\n  --src-lang json \\\n  --lang swift \\\n  --top-level Person \\\n  --out Person.swift\n\n# quicktype a directory of samples as a C++ program\n# Suppose ./blockchain is a directory with files:\n#   latest-block.json transactions.json marketcap.json\nquicktype ./blockchain -o blockchain-api.cpp\n\n# quicktype a live JSON API as a Java program\nquicktype https://api.somewhere.com/data -o Data.java\n```\n\n### Generating code from JSON schema\n\nThe recommended way to use `quicktype` is to generate a JSON schema from sample data, review and edit the schema, commit the schema to your project repo, then generate code from the schema as part of your build process:\n\n```bash\n# First, infer a JSON schema from a sample.\nquicktype pokedex.json -l schema -o schema.json\n\n# Review the schema, make changes,\n# and commit it to your project repo.\n\n# Finally, generate model code from schema in your\n# build process for whatever languages you need:\nquicktype -s schema schema.json -o src/ios/models.swift\nquicktype -s schema schema.json -o src/android/Models.java\nquicktype -s schema schema.json -o src/nodejs/Models.ts\n\n# All of these models will serialize to and from the same\n# JSON, so different programs in your stack can communicate\n# seamlessly.\n```\n\n### Generating code from TypeScript (Experimental)\n\nYou can achieve a similar result by writing or generating a [TypeScript](http://www.typescriptlang.org/) file, then quicktyping it. TypeScript is a typed superset of JavaScript with simple, succinct syntax for defining types:\n\n```typescript\ninterface Person {\n    name: string;\n    nickname?: string; // an optional property\n    luckyNumber: number;\n}\n```\n\nYou can use TypeScript just like JSON schema was used in the last example:\n\n```bash\n# First, infer a TypeScript file from a sample (or just write one!)\nquicktype pokedex.json -o pokedex.ts --just-types\n# Review the TypeScript, make changes, etc.\nquicktype pokedex.ts -o src/ios/models.swift\n```\n\n### Calling `quicktype` from JavaScript\n\nYou can use `quicktype` as a JavaScript function within `node` or browsers. First add the `quicktype-core` package:\n\n```bash\n$ npm install quicktype-core\n```\n\nIn general, first you create an `InputData` value with one or more JSON samples, JSON schemas, TypeScript sources, or other supported input types. Then you call `quicktype`, passing that `InputData` value and any options you want.\n\n```javascript\nimport {\n    quicktype,\n    InputData,\n    jsonInputForTargetLanguage,\n    JSONSchemaInput,\n    FetchingJSONSchemaStore\n} from \"quicktype-core\";\n\nasync function quicktypeJSON(targetLanguage, typeName, jsonString) {\n    const jsonInput = jsonInputForTargetLanguage(targetLanguage);\n\n    // We could add multiple samples for the same desired\n    // type, or many sources for other types. Here we're\n    // just making one type from one piece of sample JSON.\n    await jsonInput.addSource({\n        name: typeName,\n        samples: [jsonString]\n    });\n\n    const inputData = new InputData();\n    inputData.addInput(jsonInput);\n\n    return await quicktype({\n        inputData,\n        lang: targetLanguage\n    });\n}\n\nasync function quicktypeJSONSchema(targetLanguage, typeName, jsonSchemaString) {\n    const schemaInput = new JSONSchemaInput(new FetchingJSONSchemaStore());\n\n    // We could add multiple schemas for multiple types,\n    // but here we're just making one type from JSON schema.\n    await schemaInput.addSource({ name: typeName, schema: jsonSchemaString });\n\n    const inputData = new InputData();\n    inputData.addInput(schemaInput);\n\n    return await quicktype({\n        inputData,\n        lang: targetLanguage\n    });\n}\n\nasync function main() {\n    const { lines: swiftPerson } = await quicktypeJSON(\"swift\", \"Person\", jsonString);\n    console.log(swiftPerson.join(\"\\n\"));\n\n    const { lines: pythonPerson } = await quicktypeJSONSchema(\"python\", \"Person\", jsonSchemaString);\n    console.log(pythonPerson.join(\"\\n\"));\n}\n\nmain();\n```\n\nThe argument to `quicktype` is a complex object with many optional properties. [Explore its definition](https://github.com/quicktype/quicktype/blob/master/packages/quicktype-core/src/Run.ts#L637) to understand what options are allowed.\n\n### Adding Custom logic or Rendering:\n\nQuicktype supports creating your own custom languages and rendering output, you can extend existing classes or create your own to be using by the `quicktype function`.\u003cbr/\u003e\nCheck out [this guide](./doc/CustomRenderer.md) for more info.\n\n## Contributing\n\n`quicktype` is [Open Source](LICENSE) and we love contributors! In fact, we have a [list of issues](https://github.com/quicktype/quicktype/issues?utf8=✓\u0026q=is%3Aissue+is%3Aopen+label%3Ahelp-wanted) that are low-priority for us, but for which we'd happily accept contributions. Support for new target languages is also strongly desired. If you'd like to contribute, need help with anything at all, or would just like to talk things over, come [join us on Slack](http://slack.quicktype.io/).\n\n### Setup, Build, Run\n\n`quicktype` is implemented in TypeScript and requires `nodejs` and `npm` to build and run.\n\nFirst, install `typescript` globally via `npm`:\n\nClone this repo and do:\n\n#### macOS / Linux\n\n```bash\nnvm use\nnpm install\nscript/quicktype # rebuild (slow) and run (fast)\n```\n\n#### Windows\n\n```bash\nnpm install --ignore-scripts # Install dependencies\nnpm install -g typescript # Install typescript globally\ntsc --project src/cli # Rebuild\nnode dist\\cli\\index.js # Run\n```\n\n### Edit\n\nInstall [Visual Studio Code](https://code.visualstudio.com/), open this\nworkspace, and install the recommended extensions:\n\n```bash\ncode . # opens in VS Code\n```\n\n### Live-reloading for quick feedback\n\nWhen working on an output language, you'll want to view generated\noutput as you edit. Use `npm start` to watch for changes and\nrecompile and rerun `quicktype` for live feedback. For example, if you're\ndeveloping a new renderer for `fortran`, you could use the following command to\nrebuild and reinvoke `quicktype` as you implement your renderer:\n\n```bash\nnpm start -- \"--lang fortran pokedex.json\"\n```\n\nThe command in quotes is passed to `quicktype`, so you can render local `.json`\nfiles, URLs, or add other options.\n\n### Test\n\n```bash\n# Run full test suite\nnpm run test\n\n# Test a specific language (see test/languages.ts)\nFIXTURE=golang npm test\n\n# Test a single sample or directory\nFIXTURE=swift npm test -- pokedex.json\nFIXTURE=swift npm test -- test/inputs/json/samples\n```\n","funding_links":["https://github.com/sponsors/quicktype"],"categories":["TypeScript","TypeScript 相关","JavaScript框架","Table of Contents","HarmonyOS","Popular","Codegen","Node.js","csharp","Code generators","Uncategorized","typescript","Underlying Technologies"],"sub_categories":["其他_文本生成、文本对话","JSON","Windows Manager","Javascript \u0026 Typescript","Code Generator","Individual Podcast episodes","Uncategorized","TypeScript"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglideapps%2Fquicktype","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fglideapps%2Fquicktype","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fglideapps%2Fquicktype/lists"}