Is there a tool like gofmt to check the format of JSON files in a go repository? This would be used as a makefile target and git precommit hook.

I know I could code something using jq. But I bet someone has done this. Also, I prefer if it's in the go ecosystem, to make installation easier -- so I don't have to figure out how to install jq on all the different development systems that our developers use.

1 Answer 1


Check out gojq - a Pure Go implementation of jq

This is an implementation of jq command written in Go language. You can also embed gojq as a library to your Go products.

The Project seems to be actively developed and maintained. However I don't know how closely it reimplemented the featureset of, say, jq 1.5.

  • Thanks: gojq avoids jq install issues, though it doesn't work the same way as gofmt for a project. Easily scripted to achieve the effect. Commented Oct 10, 2022 at 13:05

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.