CLI reference
The gramdown command converts one Grammarly .docx export to Markdown and, by default, prints it to your terminal.
gramdown <input.docx> [options]
Positional argument
<input.docx>
The Grammarly export to convert. The path must end in .docx; gramdown rejects anything else. Required, unless --help or --version is passed.
Options
| Flag | Description |
|---|---|
-o, --output <file> |
Write the Markdown to <file> instead of stdout. |
--guess-lang |
Label each code fence with a guessed language. Off by default. |
-h, --help |
Print usage and exit. |
-v, --version |
Print the bare version string and exit. |
--guess-lang
Grammarly records no language anywhere in the .docx, so this is a pure heuristic (backed by flourite). It is reliable for things like JSON and shell, shakier on JavaScript-vs-TypeScript, and always needs a human pass.
Output
Without -o, the Markdown goes to stdout and nothing else does, so gramdown draft.docx | pbcopy and gramdown draft.docx > draft.md both work cleanly.
With -o <file>, the Markdown is written there and stdout stays empty.
Warnings
Any warning raised while reading the document (an unrecognised style, a dropped element) is printed to stderr, prefixed warning:, and does not change the exit code. Conversion still completes and the Markdown is still written.
Exit codes
| Code | When |
|---|---|
0 |
Conversion succeeded (--help / --version also exit 0). |
1 |
No arguments (usage is printed to stdout); an unknown flag or a non-.docx path; the input file does not exist; the file is not a readable .docx. |
Error messages go to stderr, prefixed error:. A malformed command line also reprints the usage text.
Examples
# to stdout
gramdown draft.docx
# to a file
gramdown draft.docx -o draft.md
# guess code-fence languages
gramdown draft.docx -o draft.md --guess-lang
# pipe somewhere else
gramdown draft.docx | pbcopy