Lua String Formatter
Lua String Formatter is a browser-based tool for formatting and beautifying Lua. Paste your input, review the result, and copy or download it. Supported processing stays in your browser; this page shows the current input-size limit before you begin.
Lua Format Reference
%s%d%f%q%c%xFrequently Asked Questions About Lua String Formatter
Which specifiers are supported?
The common C set: %d %i %o %u %x %X %c %s %q and %f, with width and precision flags.
Does it run my Lua script?
No. Only the format string and arguments are evaluated.
Does the tool execute my Lua script?
No. The tool does not run your code. In the Template view, it evaluates only the format string and arguments to generate the output. It acts as a text processor and structural checker, not an execution engine.
Which format specifiers are supported in the Template view?
You can use the standard set of C-style format specifiers, including %d, %i, %o, %u, %x, %X, %c, %s, and %q, along with +f. The tool also supports standard width and precision flags.
What should I do if I have a very large file?
The tool operates within your browser's memory limits. If you are processing a massive log file or minified response that slows down the interface, it is best to split the input into smaller, manageable chunks.
Do I need to install the tool or create an account to use it?
No. The Lua String Formatter is a fully client-side, browser-based tool. There is no installation, account creation, or remote server required to use its features.
Lua String Formatter Overview
The Lua String Formatter runs directly in your browser, turning raw or minified Lua code into a readable structure with consistent indentation. You can paste your input or upload a local file, then the tool generates the formatted output immediately without sending your code to a remote server. Because all processing happens locally, this tool is useful for inspecting sensitive configuration files or proprietary scripts without compromising data privacy.
What You Can Do
You get a clean, readable layout for your Lua code, which is helpful when:
- Reviewing logs or API responses that are currently minified.
- Preparing a pull request or documentation where consistent style is required.
- Checking configuration files for syntax errors before running them locally.
Core Workflow
Here is how to use the tool step-by-step:
- Input: Paste your raw Lua code into the "Input Lua String" panel. Alternatively, use the file button to load a local file, which the browser reads in place.
- Set Preferences: Before running the formatter, set your Indent Size to match your project's style guide. You can also choose whether to Preserve Comments.
- Process: Click the Format button to see the readable result in the "Formatted Lua" output panel.
- Export: Copy the result to your clipboard or download it to save directly into your project.
Tip: For complex transformations, keep your original text saved or in a separate buffer, as some specific formatting changes cannot be easily reversed in the browser.
Four Ways to Manipulate Your Code
Rather than treating this as a single button, the tool provides four distinct modes so you can handle different problems without re-pasting your code. You switch between these tabs instantly:
- Lua Format: Cleans up the syntax and indentation for human readability.
- Validate: Runs a syntax check to confirm the structure of your code is valid.
- Escape/Unescape: Converts special characters to their string representations and back, useful when handling configuration strings that include backslashes or quotes.
- Template: Allows you to expand string format specifiers.
Best Practices for Lua Formatting
To ensure the formatted output fits seamlessly into your existing codebase, follow these guidelines:
- Match the Indent Size to the configuration of your project's linter or style guide. This avoids the noise of reformatting that occurs when you copy pasted code back into your editor.
- Pair the output with your linter so that your formatting and validation workflows remain consistent.
- If your project uses complex string templating, verify that the output matches your intended values by checking the Validate tab.