@lukasbach/scripts

normalize-json

Runs JSON.stringify(JSON.parse()) on a file to normalize it. Normalizes with two spaces.

Usage

npx @lukasbach/scripts normalize-json

You can call the script directly if you have installed it globally:

npm i -g @lukasbach/scripts
ldo normalize-json

Options

  • --file, -f: Which file do you want to normalize?
  • -v, --verbose: Verbose logging

You can also omit options, and will be asked for them interactively.

Add --yes to skip all confirmations.

Script source

View Source on GitHub

/** Runs JSON.stringify(JSON.parse()) on a file to normalize it. Normalizes with two spaces. */

const file = await ask.text("f,file", "Which file do you want to normalize?", "file.json");
await fs.writeJSON(file, await fs.readJSON(file), { spaces: 2 });