JSON to Lua Converter
Convert JSON to Lua tables for Lua development
JSON Input
Lua Output
What Is JSON to Lua?
Lua uses tables for both objects and arrays. Libraries like json.lua or dkjson handle JSON encoding and decoding. This tool generates Lua table literals from your JSON. The JSON spec defines the format; conversion runs in your browser. Nothing is sent to a server.
How to Use This Tool
Paste or Upload JSON
Paste your JSON or upload a file. Set the table name in the config panel if you want a named variable. Invalid JSON will show an error. Use the JSON Validator to check syntax first.
Copy or Download
Use Copy or Download. For formatting JSON first, use the JSON Formatter. For validation, use the JSON Validator.
JSON to Lua Examples
Here is an example of generating Lua tables from a JSON object.
Example: Subscriber record
JSON input:
Generated Lua output:
When JSON to Lua Helps
When writing Lua scripts for games (e.g. LÖVE2D, Roblox), configs (e.g. Neovim), or embedded systems that need static data from JSON, converting to Lua tables lets you embed the structure directly. For API responses or dynamic JSON, use dkjson at runtime. This tool is useful when you have static JSON and want Lua table literals. For pulling out specific values, use the JSON Path tool.
Frequently Asked Questions
Lua table vs JSON?
JSON objects map to Lua tables with string keys. JSON arrays map to Lua tables with numeric indices (1-based in Lua). Both use the same table type. Lua tables are flexible; the generator produces literal syntax.
dkjson vs json.lua?
dkjson is feature-rich. json.lua is minimal. Both parse JSON at runtime. This tool generates static table literals.
Is my data private?
Yes. Generation runs entirely in your browser. No JSON or code is sent to any server.
Can I use in Roblox?
Yes. Roblox uses Lua (Luau). The generated tables work in Roblox scripts. For HTTP JSON responses, use HttpService:JSONDecode() and this tool for static config.
1-based indexing?
Lua arrays are 1-based. The generated output respects this. JSON arrays become Lua tables with indices starting at 1.