New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

convert_json2dts

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

convert_json2dts

a lib for converting JSON to TypeScript interfaces

latest
Source
npmnpm
Version
1.0.5
Version published
Maintainers
1
Created
Source

convert_json2dts

a lib for converting JSON to TypeScript interfaces

Installation

npm install convert_json2dts

Usage

Get TypeScript interfaces corresponding to JSON

import { JSON2Dts } from 'convert_json2dts';

const data = {
  name: 'John',
  age: 30,
};

const convert = new JSON2Dts();
const interfaces = convert.transformByJSON(data);
console.log(interfaces);
// output:
/*
interface RootType {
  name: string;
  age: number;
}
*/

// if you only have a json string you can use `transformByJSONString` method
const jsonString = JSON.stringify(data);
const interfaces_1 = JSON2Dts.transformByJSONString(jsonString);

Get .d.ts code from a JSON file

import { JSON2Dts } from 'convert_json2dts';

const json = {
  name: 'John',
  age: 30,
};

const convert = new JSON2Dts();
const interfaces = convert.convertJSONToDts(json);
console.log(interfaces);
// output:
/*
interface RootType {
    name: string;
    age: number;
}

declare const root: RootType;
export default root;
export declare const name: RootType['name'];
export declare const age: RootType['age'];
*/

Try it online

you can try it online here

Keywords

json

FAQs

Package last updated on 06 Dec 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts