A correct netlify.toml without TOML guesswork
netlify.toml configures how Netlify builds and serves your site: the build command, the publish folder, redirects, headers, and functions. TOML tables and array-of-tables syntax are easy to mistype, and a malformed file silently reverts to defaults. This builder produces valid TOML from plain inputs.
How it works
The file uses TOML tables. A [build] table holds the command and publish directory, with [build.environment] for build-time variables. Redirects use the [[redirects]] array-of-tables form, each with from, to, and status; the order is preserved because Netlify applies the first matching rule. Headers use [[headers]] with a for path pattern and a [headers.values] sub-table of header names and values. A [functions] table sets the directory Netlify deploys as serverless functions. The builder escapes string values and quotes keys where TOML requires it.
Tips and example
For a single-page app, set the publish directory to dist, then add the SPA fallback redirect from = "/*", to = "/index.html", status = 200 as the last rule. Add security headers like X-Frame-Options = "DENY" under a for = "/*" block. Put serverless functions in netlify/functions and set the functions directory accordingly. Commit the file and Netlify applies it on the next deploy.