What is JSON to Lua Table Generator?
This tool converts JSON data into Lua table definitions with proper syntax. It automatically maps JSON types to Lua types (string, number, boolean, nil) and handles nested structures as nested Lua tables.
How to Use
- Set the variable name for the generated Lua table
- Paste your JSON data into the input area
- Click "Generate" and copy the Lua code into your script
Why Use This Tool?
Tips & Best Practices
- Lua tables use 1-based indexing for arrays
- Boolean values map to Lua true/false keywords
- Null values become nil in Lua
- String keys are properly quoted
Frequently Asked Questions
How are JSON types mapped to Lua?
JSON strings become quoted Lua strings, integers and floats become unquoted Lua numbers, booleans map to Lua true/false keywords, null becomes nil, arrays become Lua tables with integer keys, and objects become Lua tables with string keys.
Does this tool handle nested JSON structures?
Yes, nested JSON objects and arrays are converted into nested Lua tables with proper indentation. Each level of nesting is indented with two spaces for readability.
What are type annotation comments?
When enabled, the tool adds Lua comments after each value indicating its inferred type (e.g., -- string, -- integer, -- boolean, -- table). This helps with code readability and documentation.
How are arrays represented in Lua?
In Lua, arrays are represented as tables with implicit integer keys starting from 1. The generated code uses the shorthand syntax {val1, val2, ...} which is equivalent to {[1]=val1, [2]=val2, ...}.
Is my data sent to a server?
No, all processing happens entirely in your browser. Your JSON data never leaves your device.