Awesome Go

bafi

CategoryText Processing
SubcategoryMarkup Languages
Stars117

Universal JSON, BSON, YAML, XML translator to ANY format using templates

About bafi

bafi

Convert JSON, XML, CSV, YAML, BSON and MT940 into any text format with templates.

One small command-line program for Windows, macOS and Linux. Read a file or a pipe, describe the output with a Go template, get JSON, XML, CSV, HTML, SQL, a SOAP request - anything that is text.

bafi -i orders.xml -t '?{{toJSON .}}'                              # XML to JSON
bafi -i users.csv -d ';' -t '?{{toJSON .}}'                        # CSV (semicolon) to JSON
curl -fs https://example.com/api/users | bafi -f json -t '?{{toXML .}}'   # REST response to XML
bafi -i sales.json -t report.tmpl -o report.html                    # HTML report from a template

Documentation · Recipes · Install · Download · Changelog

Recipes

Step-by-step, tested examples for common tasks: XML to JSON · JSON to XML · CSV to JSON · JSON to CSV · XML to CSV · REST to SOAP · SOAP to JSON · HTML report · SQL INSERTs from CSV · MT940 to CSV · Merge several files · more

Key features

  • Input: JSON, BSON, YAML, CSV (any delimiter), XML and MT940 bank statements, from a file or standard input; several files of different formats can be merged into one output.
  • Output: whatever the template produces. 60+ template functions for math, dates, strings and conversions, plus your own in Lua.
  • Errors point at the file, line and column, with a hint how to fix them.
  • Encode data as TOON for LLM prompts, or ask OpenAI about your data (experimental).
  • Try it in the browser without installing anything.

Go CodeQL Go Report Card License Mentioned in Awesome Go GitHub tag (latest by date)

If you like this app you can buy me a coffee ;)

Frequently Asked Questions

What is bafi?

bafi is a Text Processing library for the Go programming language. Universal JSON, BSON, YAML, XML translator to ANY format using templates

How do I install bafi?

Install bafi with the Go module system using `go get mmalcek/bafi`. Check the repository for the current installation instructions.

What category does bafi belong to?

bafi is listed under Text Processing, specifically Markup Languages.

← Back to Markup Languages