Skip to content

recoded-dev/json-to-properties

Repository files navigation

json-to-properties

A small CLI tool that converts JSON into Java .properties files.

Useful if you manage translations in JSON but need .properties files for Java’s ResourceBundle or Spring.


Features

  • Flattens nested JSON into dot-notation keys
  • Supports arrays (arr.0, arr.1, …)
  • Escapes keys and values for safe .properties syntax
  • Optional prefix for all keys
  • Optional sorted output for stable diffs
  • UTF-8 safe (no \uXXXX escaping by default)

Installation

Download a binary from the Releases page.

Or build from source:

git clone https://github.com/recoded-dev/json-to-properties.git
cd json-to-properties
go build -o json-to-properties .

Usage

./json-to-properties -in en.json -out messages_en.properties

Options

  • -in : input JSON file (default: stdin)
  • -out : output .properties file (default: stdout)
  • -prefix : optional prefix for all keys (e.g. app)
  • -sort : sort keys alphabetically

Example

en.json:

{
  "home": {
    "title": "Welcome",
    "cta": "Start"
  },
  "about": "About us"
}

Command:

./json-to-properties -in en.json -out messages_en.properties -sort

Output:

about=About us
home.cta=Start
home.title=Welcome

Development

Run tests:

go test

About

CLI tool to convert .json files to .properties Java resource bundles

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages