# schema-typescript

> Convert JSON Schema to TypeScript Definitions

Latest version **0.14.4** (published 2026-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install schema-typescript
pnpm add schema-typescript
yarn add schema-typescript
bun add schema-typescript
```

## Health

**Score 65/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads; pre 1.0.

## Facts

| | |
|---|---|
| Version | 0.14.4 |
| Published | 2026-07-31 |
| First published | 2024-04-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 43.9 KB |
| Known vulnerabilities | 0 (+2 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Constructive <developers@constructive.io> |
| Maintainers | pyramation, anmol1696 |
| Keywords | jsonschema, schema, typescript |

## Links

- npm: https://www.npmjs.com/package/schema-typescript
- Repository: https://github.com/constructive-io/dev-utils
- Issues: https://github.com/constructive-io/dev-utils/issues
- npm.io page: https://npm.io/package/schema-typescript

## Dependencies (5)

- [komoji](https://npm.io/package/komoji.md) 0.9.1
- [deepmerge](https://npm.io/package/deepmerge.md) ^4.3.1
- [minimatch](https://npm.io/package/minimatch.md) ^10.1.1
- [@babel/types](https://npm.io/package/@babel/types.md) ^7.28.6
- [@babel/generator](https://npm.io/package/@babel/generator.md) ^7.28.6

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.14.4 (latest) — 2026-07-31
- 0.14.3 — 2026-03-27
- 0.14.2 — 2026-03-26
- 0.14.1 — 2026-01-29
- 0.14.0 — 2026-01-20
- 0.13.14 — 2025-12-27
- 0.13.13 — 2025-12-27
- 0.13.12 — 2025-12-27
- 0.13.11 — 2025-12-17
- 0.13.10 — 2025-12-14
- 0.13.9 — 2025-11-28
- 0.13.8 — 2025-11-26
- 0.13.7 — 2025-11-25
- 0.13.6 — 2025-11-24
- 0.13.5 — 2025-11-24
- … 24 more at https://npm.io/package/schema-typescript/versions

## README

# schema-typescript 

<p align="center" width="100%">
  <img src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" height="250">
  <br/>
  JSON Schema TypeScript utilities for the Interweb
  <br />
  <a href="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml">
    <img height="20" src="https://github.com/constructive-io/dev-utils/actions/workflows/ci.yml/badge.svg" />
  </a>
  <a href="https://github.com/constructive-io/dev-utils/blob/main/LICENSE">
    <img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/>
  </a>
</p>

Welcome to _schema-typescript_! This project provides robust tools for handling JSON schemas and converting them to TypeScript interfaces with ease and efficiency.

## Features 

- **🔧 JSON Schema to TypeScript**: Convert JSON schemas into TypeScript interfaces automatically.

- **📦 Modular**: Designed to be reusable with minimal dependencies.

- **🔍 Supports `$ref` and `$defs`**: Fully supports JSON Schema references, allowing you to define complex schemas modularly.

- **🐕 Multiple Entities Handling**: Handles arrays of defined types, such as multiple dogs or cats, seamlessly in your schemas.

## Getting Started 🏁

To get started with _schema-typescript_, simply run:

```bash
npm install schema-typescript
```

## Usage 📘

Here's a quick example to show you how to convert a JSON schema into TypeScript interfaces:

```javascript
import { generateTypeScript } from 'schema-typescript';

const schema = {
    "$id": "https://example.com/person.schema.json",
    "$schema": "https://json-schema.org/draft-07/schema#",
    "title": "Person",
    "type": "object",
    "properties": {
        "firstName": { "type": "string" },
        "pets": {
            "type": "array",
            "items": { "$ref": "#/$defs/pet" }
        }
    },
    "required": ["firstName", "pets"],
    "$defs": {
        "pet": {
            "type": "object",
            "properties": {
                "name": { "type": "string" },
                "type": { "type": "string" } 
            },
            "required": ["name", "type"]
        }
    }
};

console.log(generateTypeScript(schema));
// OUTPUT:
interface Pet {
  name: string;
  type: string;
}
interface Person {
  firstName: string;
  pets: Pet[];
}
```

---

## Development

### Setup

1. Clone the repository:

```bash
git clone https://github.com/constructive-io/dev-utils.git
```

2. Install dependencies:

```bash
cd dev-utils
pnpm install
pnpm build
```

3. Test the package of interest:

```bash
cd packages/<packagename>
pnpm test:watch
```

## Credits

**🛠 Built by the [Constructive](https://constructive.io) team — creators of modular Postgres tooling for secure, composable backends. If you like our work, contribute on [GitHub](https://github.com/constructive-io).**

## Disclaimer

AS DESCRIBED IN THE LICENSES, THE SOFTWARE IS PROVIDED "AS IS", AT YOUR OWN RISK, AND WITHOUT WARRANTIES OF ANY KIND.

No developer or entity involved in creating this software will be liable for any claims or damages whatsoever associated with your use, inability to use, or your interaction with other users of the code, including any direct, indirect, incidental, special, exemplary, punitive or consequential damages, or loss of profits, cryptocurrencies, tokens, or anything else of value.

---
_Source: https://npm.io/package/schema-typescript · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
