Pandoc is an open-source tool that can convert between multiple markup formats.

How to use

 pandoc -i input.txt -o output.file

convert between specific formats

pandoc -f markdown -t mediawiki test.md pandoc --from markdown --to mediawiki text.md

create a pdf

pandoc test.txt -o test.pdf

convert a webpage to markdown

pandoc -f html -t markdown https://pandoc.org/MANUAL.html

convert an epub to markdown

Replace TITLE , Source, and Output in this command: pandoc -t markdown_strict-raw_html-native_divs-native_spans-fenced_divs-bracketed_spans+footnotes-blank_before_header-space_in_atx_header-header_attributes-implicit_header_references --wrap=none --extract-media="TITLE" -s "Source.epub" -o "Output.md"


General options

-f FORMAT, -r FORMAT, --from=FORMAT, --read=FORMAT

Specify input format. FORMAT can be:

Extensions can be individually enabled or disabled by appending +EXTENSION or -EXTENSION to the format name. See Extensions below, for a list of extensions and their names. See --list-input-formats and --list-extensions, below.

-t FORMAT, -w FORMAT, --to=FORMAT, --write=FORMAT

Specify output format. FORMAT can be:

Note that odt, docx, epub, and pdf output will not be directed to stdout unless forced with -o -.

Extensions can be individually enabled or disabled by appending +EXTENSION or -EXTENSION to the format name. See Extensions below, for a list of extensions and their names. See --list-output-formats and --list-extensions, below.

  • -o FILE, --output=FILE

    - Write output to FILE instead of stdout. If FILE is -, output will go to stdout, even if a non-textual format (docx, odt, epub2, epub3) is specified.

  • --data-dir=DIRECTORY

    - Specify the user data directory to search for pandoc data files. If this option is not specified, the default user data directory will be used. On *nix and macOS systems this will be the pandoc subdirectory of the XDG data directory (by default, $HOME/.local/share, overridable by setting the XDG_DATA_HOME environment variable). If that directory does not exist, $HOME/.pandoc will be used (for backwards compatibility). In Windows the default user data directory is C:\Users\USERNAME\AppData\Roaming\pandoc. You can find the default user data directory on your system by looking at the output of pandoc --version. A reference.odt, reference.docx, epub.css, templates, slidy, slideous, or s5 directory placed in this directory will override pandoc’s normal defaults.

  • -d FILE, --defaults=FILE

    - Specify a set of default option settings. FILE is a YAML file whose fields correspond to command-line option settings. All options for document conversion, including input and output files, can be set using a defaults file. The file will be searched for first in the working directory, and then in the defaults subdirectory of the user data directory (see --data-dir). The .yaml extension may be omitted. See the section Default files for more information on the file format. Settings from the defaults file may be overridden or extended by subsequent options on the command line.

  • --bash-completion

    - Generate a bash completion script. To enable bash completion with pandoc, add this to your .bashrc:


eval "$(pandoc --bash-completion)"

  • --verbose

    - Give verbose debugging output.

  • --quiet

    * Suppress warning messages.

  • --fail-if-warnings

    - Exit with error status if there are any warnings.

  • --log=FILE

    - Write log messages in machine-readable JSON format to FILE. All messages above DEBUG level will be written, regardless of verbosity settings (--verbose, --quiet).

  • --list-input-formats

    - List supported input formats, one per line.

  • --list-output-formats

    - List supported output formats, one per line.

  • --list-extensions[   =FORMAT]

    - List supported extensions for FORMAT, one per line, preceded by a + or - indicating whether it is enabled by default in FORMAT. If FORMAT is not specified, defaults for pandoc’s Markdown are given.

  • --list-highlight-languages

    - List supported languages for syntax highlighting, one per line.

  • --list-highlight-styles

    - List supported styles for syntax highlighting, one per line. See --highlight-style.

  • -v, --version

    - Print version.

  • -h, --help

    - Show usage message.