Lua to JSON Converter
Paste a Lua table. Get JSON back.
What this tool does
If you have ever had a Lua table from a game config, a Redis script, or an nginx OpenResty handler and needed it as JSON, this does the conversion in one paste. No need to install json.lua or dkjson just to serialize a constant.
Lua tables are tricky because they mix array-part (integer keys starting at 1) and hash-part (string/mixed keys) in the same structure. The converter detects which shape you have: a pure array-part table becomes a JSON array, a pure hash-part table becomes a JSON object, and a mixed table falls back to a JSON object with the numeric keys stringified. That matches what the Lua 5.4 reference manual describes and what the popular JSON libraries do.
Nested tables go as deep as you want. nil becomes null, true/false map straight across, numbers stay numbers (integers stay integers). Strings using single quotes, double quotes, or long brackets ([[...]]) all parse correctly. Comments (-- and --[[ ... ]]) are stripped.
How to use it
Three steps. Works for small tables and sprawling configs alike.
Paste your Lua (or try the sample)
Drop your Lua table into the left editor. An array-part table, a hash-part table, nested tables, or multiple top-level local x = {...} declarations — all fine.
Leave the Lua syntax alone. Keys without quotes (name = "..."), keys with brackets (["foo-bar"] = ...), and comments all parse correctly.
Hit Convert
Click the green Convert button. The tool walks the table, detects array vs hash shape at each level, and emits matching JSON.
Copy the JSON
Copy the indented JSON from the right panel into a config file, an API call, or a test fixture. Done.
When this actually comes in handy
Migrating game/engine configs
Many engines (Love2D, Defold, World of Warcraft addons) use Lua tables for config. When the pipeline moves to JSON-driven tooling, this is the one-shot conversion.
OpenResty / Nginx handler debugging
You built a response body as a Lua table in an OpenResty script — paste it here to see the JSON the client will receive, before a redeploy.
Redis Lua scripts
A Redis EVAL script returns a complex structure; the Lua table literal is easy to capture from logs. Convert to JSON to compare with what the app sees.
Porting config to another language
Moving from a Lua-scripted tool to a Node or Go rewrite. Convert the old config tables to JSON as the migration format.
Common questions
How does it decide array vs object?
Same rule json.lua uses: if the table has only consecutive integer keys starting at 1, it is an array. Otherwise it is an object. Mixed tables (1, 2, "name") come out as objects with numeric keys stringified, because JSON arrays cannot have named keys.
What about nil in a table?
A nil value removes that key in Lua — the converter follows the same rule and simply omits nil-valued keys from the output. A standalone nil (e.g. local x = nil) becomes JSON null.
Does it support long-bracket strings like <code>[[...]]</code>?
Yes. Long-bracket strings (including [==[...]==] with any level of equals signs) are parsed and emitted as JSON strings with proper escaping.
Can I paste multiple tables?
Yes. Each top-level local name = {...} or name = {...} becomes a key in the output JSON. Anonymous trailing tables get numeric keys. Nothing is silently dropped.
Is my code stored?
No — we send it to the backend for conversion and do not persist it. Still, redact anything sensitive before pasting.
Does it handle LuaRocks-style rockspec files?
Yes. Rockspec files are Lua tables at heart, so they convert cleanly — handy for migrating dependency metadata to a JSON registry format.
Other tools you may need
Lua to JSON pairs well with the rest of the toolbox: