Install $ go get github.com/pib/gofmt-inline-json Use $ gofmt-inline-json somefile.go Or, if you want to replace the original file with the reformatted one: $ gofmt-inline-json -w somefile.go