A Visual Studio Code extension that converts JSON into Go struct definitions.

Usage
- Open a JSON document in VS Code, or select a JSON value.
- Run Convert JSON to Go Struct from the Command Palette, the JSON editor context menu, or
Ctrl+Alt+G(Cmd+Alt+Gon macOS). - Paste the generated Go code from the clipboard.
The command prefers non-empty selected text and otherwise converts the complete active document. It supports objects, nested objects, primitive and object arrays, top-level arrays, and top-level primitives. Empty or heterogeneous arrays use []any; null uses any. Generated fields are exported and preserve their original keys in json tags.
Development
npm install
npm run verify
Use the Run Extension launch configuration to start an Extension Development Host.
The extension uses a dependency-free conversion core, Jest tests, ESLint, and a Vite production bundle. Run npm run verify before publishing.
Output policy
- A top-level object becomes a named Go struct.
- A top-level array becomes a named alias to a slice by default.
- A top-level primitive becomes a named alias to its Go primitive type.
- Empty arrays use
[]any, heterogeneous arrays use[]any, andnullusesanywhen no more specific context is available.
Support
If you find this extension useful, consider supporting its development by buying me a coffee! Your support helps me continue improving and maintaining the extension.
