Go Formatter Online (gofmt)
Paste Go source code, hit Format, and get exactly what gofmt produces: tab indentation, aligned operators, grouped imports and struct fields lined up by the longest name. The rules come from real gofmt, not a regex approximation.
The formatting engine is Go's official go/format package compiled to WebAssembly, so every calculation happens in your browser and your code is never sent anywhere. That is the difference from most "online formatters" — it keeps working offline, and pasting company code carries no leak risk.
Features
- Real gofmt rules — The engine is Go's official go/format package compiled to WebAssembly with TinyGo. Output is byte-for-byte identical to the command-line gofmt, tabs and alignment included.
- Runs in your browser — The 268 KB wasm engine is self-hosted and warms up in the background after page load. Formatting is fully local — your code never leaves your device.
- Syntax error positions — Invalid code produces Go-compiler-style messages with line:column and a reason, pointing straight at the problem.
- Copy or download — Copy the result in one click or download it as a .go file. Code that is already gofmt-formatted comes back unchanged.
- No sign-up, no ads — Open the page and use it. No accounts, no queues, no limits, no ads or pop-ups.
- Go resources included — The site also has a Go toolchain cheatsheet, a deep dive on gofmt vs goimports, and copy-ready Go snippets to go with this tool.
How to use
- Paste Go source code into the left editor, or click "Example" to load an unformatted demo.
- Click "Format" — the gofmt output appears on the right immediately.
- Click "Copy" to put the result on your clipboard, or "Download" to save it as a .go file.
- If a syntax error is reported, fix the line:column it points to and format again.
FAQ
Is my code uploaded to a server?
No. The formatting engine is Go compiled to WebAssembly and runs in your browser; the page contains no code that sends your source anywhere. You can disconnect from the network and keep using this page (the first load needs the network to fetch the wasm engine file).
Is the output identical to the command-line gofmt?
Yes. The engine is Go's official go/format package and applies the same rules as go fmt. The only difference is that the CLI version reads and writes files, while this tool works on pasted text.
Why are there no options for indent width or quote style?
Because gofmt's design philosophy is "no configuration" — every Go codebase in the world looks the same, and that is precisely its value over other languages' formatters. This tool deliberately offers no knobs either.
Does it organise imports like goimports?
No. goimports adds and removes imports based on dependency information, which cannot be fully done in a pure front end. This tool only formats, exactly like gofmt. Read the site blog post "gofmt vs goimports" for the difference.
How large a file can it handle?
Files of a few hundred KB are no problem (a 3000-line file formats in about 130 ms in testing). For anything larger, use the command-line gofmt — the editor input experience reaches its limits first anyway.