Thrift to JSON
Convert Java Thrift toString() output to formatted JSON — instantly.

Features
- 🚀 One command — keyboard shortcut, right-click menu, or command palette
- 🔁 Recursive parsing — handles arbitrarily nested Thrift objects
- 🔗 URL-safe — preserves full URLs containing
://, &, =, %3A, etc.
- 📦 Embedded JSON — fields whose value is a JSON string are parsed into objects
- 🗺 Dual map separators — handles both
: and = as map key-value separators
- 🔢 Integer precision — integers beyond
Number.MAX_SAFE_INTEGER are kept as strings
- 📋 Side-by-side result — opens converted JSON in a new tab with syntax highlighting
- 📎 Copy to clipboard — one-click copy from the notification bar
Usage
Method 1 — Keyboard Shortcut
Select the Thrift text (or select nothing to convert the whole document), then press:
| OS |
Shortcut |
| macOS |
Cmd + Alt + J |
| Windows / Linux |
Ctrl + Alt + J |
Select text → right-click → Convert Thrift to JSON
Method 3 — Command Palette
Cmd+Shift+P (macOS) / Ctrl+Shift+P → type Thrift: Convert to JSON
This extension parses the standard Java Thrift toString() format:
ClassName(field1:value1, field2:NestedClass(x:1, y:2), list:[a, b, c])
Supported Patterns
Basic object
UserInfo(userId:12345, name:Alice, active:true)
{ "userId": 12345, "name": "Alice", "active": true }
Nested objects
Response(code:1, data:UserInfo(userId:12345, name:Alice))
{ "code": 1, "data": { "userId": 12345, "name": "Alice" } }
Map with = separator (common in Thrift extraData fields)
Config(params:{timeout=30, retry=3, debug=})
{ "params": { "timeout": 30, "retry": 3, "debug": null } }
Map with list value
Result(items:{key=[ObjA(x:1), ObjB(x:2)]})
{ "items": { "key": [{ "x": 1 }, { "x": 2 }] } }
URL field (special characters preserved)
Info(linkUrl:https://example.com/path?a=1&b=2, id:42)
{ "linkUrl": "https://example.com/path?a=1&b=2", "id": 42 }
Embedded JSON string
Meta(token:{"type":"coupon","id":"123"}, valid:true)
{ "token": { "type": "coupon", "id": "123" }, "valid": true }
Empty / null fields
Address(street:Main St, unit:, zip:)
{ "street": "Main St", "unit": null, "zip": null }
Parsing Rules
| Input value |
JSON output |
true / false |
boolean |
null / None |
null |
| Integer (within safe range) |
number |
| Integer (> 2⁵³) |
string — precision preserved |
| Float |
number |
ClassName(...) |
object (class name discarded) |
{k:v} / {k=v} |
object |
[a, b] |
array |
"quoted" |
string |
| Everything else |
string |
Extension Settings
No configuration required. Works out of the box.
Known Limitations
- Class names are discarded (only field values are kept)
- String values are unquoted in the original format — if a value contains
, or ), parsing may be ambiguous. In practice this does not occur with standard Thrift output.
中文说明
一键将 Java Thrift 对象 toString() 输出转换为格式化 JSON。
功能特性
- 🚀 一个命令搞定 — 快捷键、右键菜单、命令面板均可触发
- 🔁 递归解析 — 支持任意深度的嵌套 Thrift 对象
- 🔗 URL 安全 — 完整保留含
://、&、=、%3A 等特殊字符的 URL
- 📦 内嵌 JSON — 字段值为 JSON 字符串时自动解析为对象
- 🗺 双分隔符 Map — 同时支持
: 和 = 作为 key-value 分隔符
- 🔢 大整数精度 — 超过 JS 安全整数范围的值保留为字符串,不丢失精度
- 📋 侧边新标签 — 转换结果在右侧新标签页打开,带 JSON 语法高亮
- 📎 一键复制 — 通知栏提供「复制到剪贴板」按钮
使用方式
方式一:快捷键
选中 Thrift 文本(不选则转换整个文档),按:
| 系统 |
快捷键 |
| macOS |
Cmd + Alt + J |
| Windows / Linux |
Ctrl + Alt + J |
方式二:右键菜单
选中文本 → 右键 → Convert Thrift to JSON
方式三:命令面板
Cmd+Shift+P(macOS)/ Ctrl+Shift+P → 输入 Thrift: Convert to JSON
输入格式
本插件解析标准 Java Thrift toString() 格式的文本,典型结构如下:
ClassName(field1:value1, field2:NestedClass(x:1, y:2), list:[a, b, c])
支持以下所有格式(示例见英文说明部分):
| 模式 |
说明 |
| 基本对象 |
ClassName(k:v, ...) → {} 对象,类名丢弃 |
| 嵌套对象 |
递归解析,任意深度 |
= 分隔 Map |
{key=value} → {} 对象 |
| Map 嵌套 List |
{key=[...]} → 正常解析 |
| URL 字段 |
含特殊字符的 URL 完整保留 |
| 内嵌 JSON |
{"k":"v"} 格式的值解析为对象 |
| 空值字段 |
field: → null |
| 超大整数 |
超过 2⁵³ 的整数保留为字符串 |
License
MIT