Dev HelpersOpen library
← Back

Parse command-line options

Parse command-line options in JavaScript.

Open this example in the interactive library

Source code

import { parseArgs } from "node:util";
const { values } = parseArgs({
  args: ["--format", "json", "--quiet"],
  options: { format: { type: "string" }, quiet: { type: "boolean" } },
});
console.log(values);

Sample output

[Object: null prototype] { format: 'json', quiet: true }