HackerReposA FIELD GUIDE TO OPEN SOURCE
ProSponsor the shelf♧ 0
← Back to top all-time
bcherny
json-schema-to-typescript
TypeScript2016–2023
bcherny / json-schema-to-typescript

json-schema-to-typescript

Compile JSON Schema to TypeScript type declarations

6Distinct people
13Mentions
0Explicit recommenders
3.4KGitHub stars
REPOSITORY AT A GLANCE

What to know before exploring

What it is

Compile JSON Schema to TypeScript type declarations

GitHub

Where it is used

No documented product use has been verified yet.

What people are saying

No recommendation phrase was found in the indexed comments.

No classified warning is attached to this page. Read the discussions before treating silence as approval.

Also in these discussions

Mentioned in the same Hacker News threads. That is not proof they are substitutes.

This week on Hacker News

Nov 7–Nov 14 UTC · Direct repository links and separately labeled related project stories. Indexed through 11/14/2026, 3:56:07 PM UTC.

No direct repository links were found in the indexed HN discussions over the past seven days. Older discussions are available below.

Mentions over time

HN mentions by year13 dated mentions

Observed mentions: 2016-05-19 16:58:23 UTC to 2023-10-06 11:55:49 UTC.

0123452016-01-01 00:00:00 UTC to 2017-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments20162017-01-01 00:00:00 UTC to 2018-01-01 00:00:00 UTC (exclusive): 5 mentions; 1 submissions, 4 comments2018-01-01 00:00:00 UTC to 2019-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2019-01-01 00:00:00 UTC to 2020-01-01 00:00:00 UTC (exclusive): 2 mentions; 0 submissions, 2 comments20192020-01-01 00:00:00 UTC to 2021-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2021-01-01 00:00:00 UTC to 2022-01-01 00:00:00 UTC (exclusive): 0 mentions; 0 submissions, 0 comments2022-01-01 00:00:00 UTC to 2023-01-01 00:00:00 UTC (exclusive): 3 mentions; 0 submissions, 3 comments2023-01-01 00:00:00 UTC to 2024-01-01 00:00:00 UTC (exclusive): 1 mentions; 0 submissions, 1 comments2023

Counts come from the repository’s dated source evidence. Index cutoff: 2026-11-02 08:16:59 UTC.

View mention counts and date ranges
UTC ranges include their start and exclude their end. Select a period to filter the source evidence.
PeriodStart (UTC)End (exclusive, UTC)MentionsSubmissionsComments
20162016-01-01 00:00:00 UTC2017-01-01 00:00:00 UTC101
20172017-01-01 00:00:00 UTC2018-01-01 00:00:00 UTC514
20182018-01-01 00:00:00 UTC2019-01-01 00:00:00 UTC000
20192019-01-01 00:00:00 UTC2020-01-01 00:00:00 UTC202
20202020-01-01 00:00:00 UTC2021-01-01 00:00:00 UTC101
20212021-01-01 00:00:00 UTC2022-01-01 00:00:00 UTC000
20222022-01-01 00:00:00 UTC2023-01-01 00:00:00 UTC303
20232023-01-01 00:00:00 UTC2024-01-01 00:00:00 UTC101

What Hacker News says

13 sources
jsonnet is my go-to language for anything related to configuration, after having tried json, yaml, TS, edn, and tasting dhall and toml. It addresses all problems in the article and more. the composition model strikes a good balance between data extensibility / language expressiveness / ease of use. the generated json leads to easy-to-understand and portable data, and if you write jsonschemas from jsonnet, tools like json-schema-to-typescript [1] make it easy to import a consistent interface, and almost every language has a reasonably up-to-date validation library. [1] https://github.com/bcherny/json-schema-to-typescript
In Why JSON Isn’t A Good Configuration Language (2018)
What I was most curious about was how they achieved run-time type checking in TypeScript. In this case, it was done by code generation using: https://github.com/bcherny/json-schema-to-typescript Personally, I'd prefer a way that doesn't involve another build step. A popular library I've often seen mentioned is io-ts: https://github.com/gcanti/io-ts One that I've taken a liking to, backed by ajv for JSON schema validation, is: https://github.com/andnp/ValidTyped
In Validating Data with JSON Schema, Angular and TypeScript
This hasn’t been accurate for at least 2 years. - Use the —noImplicitAny flag to prevent implicitly using any (and if you really want — I don’t think you do, but you can — completely ban any with TSLint) - Use the —strictNullChecks flag to promote null and undefined to explicit types Or, use —strict to do both of those and more. Example tsconfig.json: https://github.com/bcherny/json-schema-to-typescript/blob/ma... Btw, what specifically is indecent about TS’s type guards?
In Migrate Jest to TypeScript
Yes, a runtime check in TypeScript is the same as a runtime check in JavaScript. function inc(n) { if (typeof n === 'number') { return n + 1 } throw new Error('Parameter n is not a number'); } If you wanted to actually runtime check all types (probably not advised) you could parse the type annotations. Or you could define your types using something like JSON Schema and validate against that. https://github.com/bcherny/json-schema-to-typescript https://github.com/YousefED/typescript-json-schema
In JavaScript for People Who Hate JavaScript
JSONSchema has a concept of "$refs", which is a way to encode a pointer to a value in a JSONSchema. $refs can point to another node in the same graph, a node in another JSONSchema on the same filesystem, or a node in another JSONSchema fetched over the network. $refs are used in JSONSchema, but are described in the separate JSONPointer spec [0]. See unit tests for examples: - In-file $ref: https://github.com/bcherny/json-schema-to-typescript/blob/ma... - Local $ref: https://github.com/bcherny/json-schema-to-typescript/blob/ma... - Remote $ref: https://github.com/bcherny/json-schema-to-typescript/blob/ma... - Cyclical $ref: https://github.com/bcherny/json-schema-to-typescript/blob/ma... Hope that helps! [0] https://tools.ietf.org/html/rfc6901
In Show HN: JSONSchema to TypeScript compiler

MAKE YOURSELF AT HOME

A few shortcuts

/
Search the collection
?
Open this guide
Esc
Close dialogs and navigation

Your saved repositories and interests stay in this browser.