# json-to-ts-types

> A utility for generating TypeScript type declarations from JSON data with customizable type names.

Latest version **1.0.8** (published 2024-02-24) · ISC license · 0 weekly downloads

## Install

```sh
npm install json-to-ts-types
pnpm add json-to-ts-types
yarn add json-to-ts-types
bun add json-to-ts-types
```

Provides the command `jttt`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.8 |
| Published | 2024-02-24 |
| First published | 2024-02-18 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Kozlove1 |
| Maintainers | kozlove1 |
| Keywords | JSON, TypeScript, type generator, type declaration, conversion, utility, tool, development, automation, customization, CLI, code generation |

## Links

- npm: https://www.npmjs.com/package/json-to-ts-types
- Repository: https://github.com/Kozlove1/json-to-ts-types
- Homepage: https://github.com/Kozlove1/json-to-ts-types#readme
- Issues: https://github.com/Kozlove1/json-to-ts-types/issues
- npm.io page: https://npm.io/package/json-to-ts-types

## 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

- 1.0.8 (latest) — 2024-02-24
- 1.0.7 — 2024-02-18
- 1.0.6 — 2024-02-18
- 1.0.5 — 2024-02-18
- 1.0.4 — 2024-02-18
- 1.0.3 — 2024-02-18
- 1.0.2 — 2024-02-18
- 1.0.1 — 2024-02-18
- 1.0.0 — 2024-02-18

## README

JSON to TypeScript Type Generator
=============

This npm package allows you to generate TypeScript type declarations from JSON data with customizable type names.

Installation
=============
Using npm:

npm install --save-dev json-to-ts-types

npm install -g json-to-ts-types

Using yarn:

yarn add --dev package-name

yarn global add json-to-ts-types

Usage
=============
After installing the package globally, you can use it from any directory on your system.

Run the package with the following command:


jttt inputPath outputPath typeName

Replace <inputPath> with the path to the input JSON file, <outputPath> with the desired path for the TypeScript type file to be generated, and <typeName> with the name you want to assign to the TypeScript type.

Example
=============

Suppose you have a JSON file named data.json containing the following data:


{
  "name": "Robert Anthony Plant",
  "age": 75,
  "address": {
    "city": "West Bromwich",
    "country": "Great Britain"
  }
}
To generate a TypeScript type declaration for this data, run the following command:


jttt data.json types.ts LedZeppelin

This will create a TypeScript file named types.ts with the following type declaration:


export type LedZeppelin = 'name' | 'age' | 'address.city' | 'address.country';

Notes
=============

Ensure that Node.js is installed on your system.
You must have appropriate permissions to execute the script and read/write files in the specified directories.

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