Go Formatter
Run gofmt itself — the formatter from the Go toolchain, compiled to WebAssembly — in your browser. The output is canonical gofmt style, tabs and all, and there is deliberately nothing to configure.
Programming Language ToolsHow to use Go Formatter
- Paste Go source into the input panel.
- Press Format. gofmt loads on first use, then runs instantly.
- Copy the result or download it as formatted.go.
- A syntax error is reported with gofmt's own message and position.
Examples
Before
Valid Go, but not gofmt'd.
package main
import ("fmt"
"strings")
func main(){
fmt.Println(strings.ToUpper("hi"))}After
Canonical gofmt output, with tab indentation.
package main
import (
"fmt"
"strings"
)
func main() {
fmt.Println(strings.ToUpper("hi"))
}Features
- Genuinely gofmt: the Go toolchain's formatter compiled to WebAssembly
- Canonical Go style — no options, by design
- Aligns struct fields, const blocks and comments the way the toolchain does
- Groups and formats import blocks
- Reports syntax errors with gofmt's own message
- Copy to clipboard or download formatted.go
- Only 260 KB, downloaded when you press Format
- Runs entirely in your browser
Frequently asked questions
- Is this really gofmt?
- Yes. It is the gofmt implementation from the Go project compiled to WebAssembly, so the output is byte-identical to running gofmt locally.
- Why are there no indentation options?
- Because gofmt has none. Go deliberately has one canonical format, which is why Go code looks the same everywhere. Offering spaces here would produce output that is not gofmt'd.
- Does it run goimports as well?
- No. gofmt formats existing imports but does not add or remove them; goimports is a separate tool that needs to resolve packages, which is not possible in a browser.
- Will it fix my syntax errors?
- No. gofmt must parse the file first, so a syntax error stops it and the error message tells you where.
- Does it work on a fragment?
- gofmt expects a complete file, starting with a package clause. A bare function body will be rejected as a parse error.
- Is my code uploaded?
- No. The WebAssembly module runs locally and nothing leaves your browser.
Related tools
About Go Formatter
Go Formatter is part of Programming Language Tools on ToolHive, a growing collection of small, focused utilities for developers, designers and students. Formatters and playgrounds for Python, C, Java, Go, Rust and SQL. Everything runs client-side, so your data never leaves the browser tab — which makes these tools safe to use with work-in-progress code and private content.