A simple Neovim plugin to convert JSON to TypeScript interfaces.
- Converts JSON in current buffer to TypeScript interfaces
- Handles nested objects, arrays and creates separate interfaces
- Automatically copies result to system clipboard
- Sorts properties alphabetically for consistency
{
"I2olanD/jtt.nvim",
lazy = false,
config = function()
require('jtt').setup()
end,
keys = {
{ "<leader>jtt", "<cmd>JsonToTypeScript<cr>", desc = "Copy json to TS" }
}
}- Open a JSON file in Neovim
- Run
:JsonToTypeScript - The TypeScript interfaces will be copied to your clipboard
Input JSON:
{
"user": {
"id": 1,
"name": "John"
},
"posts": [
{
"title": "Hello",
"content": "World"
}
]
}Output TypeScript:
interface Posts {
content: string;
title: string;
}
interface User {
id: number;
name: string;
}
interface Root {
posts: Posts[];
user: User;
}