{
    "mode": "man",
    "parameter": "pygmentize",
    "section": "1",
    "url": "https://www.chedong.com/phpMan.php/man/pygmentize/1/json",
    "generated": "2026-09-01T10:46:09Z",
    "synopsis": "pygmentize        [-l <lexer> | -g] [-F <filter>[:<options>]] [-f <formatter>]       [-O <op‐\ntions>] [-P <option=value>] [-o <outfile>] [<infile>]\npygmentize -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>]\npygmentize -L [<which> ...]\npygmentize -N <filename>\npygmentize -C\npygmentize -H <type> <name>\npygmentize -h | -V",
    "sections": {
        "NAME": {
            "content": "pygmentize - highlights the input file\n\n",
            "subsections": []
        },
        "SYNOPSIS": {
            "content": "pygmentize        [-l <lexer> | -g] [-F <filter>[:<options>]] [-f <formatter>]       [-O <op‐\ntions>] [-P <option=value>] [-o <outfile>] [<infile>]\npygmentize -S <style> -f <formatter> [-a <arg>] [-O <options>] [-P <option=value>]\npygmentize -L [<which> ...]\npygmentize -N <filename>\npygmentize -C\npygmentize -H <type> <name>\npygmentize -h | -V\n\n",
            "subsections": []
        },
        "DESCRIPTION": {
            "content": "Pygments is a generic syntax highlighter for general use in all kinds of software such as fo‐\nrum systems, wikis or other applications that need to prettify source code.\n\nIts highlights are:\n* a wide range of common languages and markup formats is supported\n* special attention is paid to details, increasing quality by a fair amount\n* support for new languages and formats are added easily\n* a number of output formats, presently HTML, LaTeX and ANSI sequences\n* it is usable as a command-line tool and as a library\n* ... and it highlights even Brainfuck!\n\npygmentize is a command that uses Pygments to highlight the input file and write  the  result\nto <outfile>. If no <infile> is given, stdin is used.\n",
            "subsections": []
        },
        "OPTIONS": {
            "content": "A summary of options is included below.\n",
            "subsections": [
                {
                    "name": "-l _",
                    "content": "Set the lexer name. If not given, the lexer is guessed from the extension of the input\nfile name (this obviously doesn't work if the input is stdin).\n",
                    "flag": "-l"
                },
                {
                    "name": "-g",
                    "content": "this fails (this option works for highlighting standard input).\n",
                    "flag": "-g"
                },
                {
                    "name": "-F _",
                    "content": "Add a filter to the token stream. You can give options in the same way as for -O after\na colon (note: there must not be spaces around the colon).  This option can  be  given\nmultiple times.\n",
                    "flag": "-F"
                },
                {
                    "name": "-f _",
                    "content": "Set  the  formatter  name.  If not given, it will be guessed from the extension of the\noutput file name. If no output file is given, the terminal formatter will be  used  by\ndefault.\n",
                    "flag": "-f"
                },
                {
                    "name": "-o _",
                    "content": "Set output file. If not given, stdout is used.\n",
                    "flag": "-o"
                },
                {
                    "name": "-O _",
                    "content": "With  this  option, you can give the lexer and formatter a comma-separated list of op‐\ntions, e.g. \"-O bg=light,python=cool\". Which options are valid for  which  lexers  and\nformatters  can  be  found  in  the  documentation.  This option can be given multiple\ntimes.\n",
                    "flag": "-O"
                },
                {
                    "name": "-P _",
                    "content": "This option adds lexer and formatter options like the -O option, but you can only give\none option per -P. That way, the option value may contain  commas  and  equals  signs,\nwhich it can't with -O.\n",
                    "flag": "-P"
                },
                {
                    "name": "-S _",
                    "content": "Print  out  style  definitions  for  style <style> and for formatter <formatter>.  The\nmeaning of the argument given by -a <arg> is formatter dependent and can be  found  in\nthe documentation.\n",
                    "flag": "-S"
                },
                {
                    "name": "-L [_",
                    "content": "List  lexers, formatters, styles or filters. Set <which> to the thing you want to list\n(e.g. \"styles\"), or omit it to list everything.\n",
                    "flag": "-L"
                },
                {
                    "name": "-N _",
                    "content": "Guess and print out a lexer name based solely on the given filename.   Does  not  take\ninput or highlight anything.  If no specific lexer can be found, \"text\" is printed.\n",
                    "flag": "-N"
                },
                {
                    "name": "-C",
                    "content": "",
                    "flag": "-C"
                },
                {
                    "name": "-H _",
                    "content": "Print  detailed  help  for  the  object  <name> of type <type>, where <type> is one of\n\"lexer\", \"formatter\" or \"filter\".\n",
                    "flag": "-H"
                },
                {
                    "name": "-h",
                    "content": "",
                    "flag": "-h"
                },
                {
                    "name": "-V",
                    "content": "",
                    "flag": "-V"
                }
            ]
        },
        "SEE ALSO": {
            "content": "/usr/share/doc/python-pygments-doc/index.html\n",
            "subsections": []
        },
        "AUTHOR": {
            "content": "pygmentize was written by Georg Brandl <g.brandl@gmx.net>.\n\nThis manual page was written by Piotr Ozarowski <ozarow@gmail.com>, for  the  Debian  project\n(but may be used by others).\n\nJanuary 20, 2021                             PYGMENTIZE(1)",
            "subsections": []
        }
    },
    "summary": "pygmentize - highlights the input file",
    "flags": [
        {
            "flag": "-l",
            "long": null,
            "arg": null,
            "description": "Set the lexer name. If not given, the lexer is guessed from the extension of the input file name (this obviously doesn't work if the input is stdin)."
        },
        {
            "flag": "-g",
            "long": null,
            "arg": null,
            "description": "this fails (this option works for highlighting standard input)."
        },
        {
            "flag": "-F",
            "long": null,
            "arg": null,
            "description": "Add a filter to the token stream. You can give options in the same way as for -O after a colon (note: there must not be spaces around the colon). This option can be given multiple times."
        },
        {
            "flag": "-f",
            "long": null,
            "arg": null,
            "description": "Set the formatter name. If not given, it will be guessed from the extension of the output file name. If no output file is given, the terminal formatter will be used by default."
        },
        {
            "flag": "-o",
            "long": null,
            "arg": null,
            "description": "Set output file. If not given, stdout is used."
        },
        {
            "flag": "-O",
            "long": null,
            "arg": null,
            "description": "With this option, you can give the lexer and formatter a comma-separated list of op‐ tions, e.g. \"-O bg=light,python=cool\". Which options are valid for which lexers and formatters can be found in the documentation. This option can be given multiple times."
        },
        {
            "flag": "-P",
            "long": null,
            "arg": null,
            "description": "This option adds lexer and formatter options like the -O option, but you can only give one option per -P. That way, the option value may contain commas and equals signs, which it can't with -O."
        },
        {
            "flag": "-S",
            "long": null,
            "arg": null,
            "description": "Print out style definitions for style <style> and for formatter <formatter>. The meaning of the argument given by -a <arg> is formatter dependent and can be found in the documentation."
        },
        {
            "flag": "-L",
            "long": null,
            "arg": null,
            "description": "List lexers, formatters, styles or filters. Set <which> to the thing you want to list (e.g. \"styles\"), or omit it to list everything."
        },
        {
            "flag": "-N",
            "long": null,
            "arg": null,
            "description": "Guess and print out a lexer name based solely on the given filename. Does not take input or highlight anything. If no specific lexer can be found, \"text\" is printed."
        },
        {
            "flag": "-C",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-H",
            "long": null,
            "arg": null,
            "description": "Print detailed help for the object <name> of type <type>, where <type> is one of \"lexer\", \"formatter\" or \"filter\"."
        },
        {
            "flag": "-h",
            "long": null,
            "arg": null,
            "description": ""
        },
        {
            "flag": "-V",
            "long": null,
            "arg": null,
            "description": ""
        }
    ],
    "examples": [],
    "see_also": [],
    "tldr": {
        "source": "official",
        "description": "Python-based syntax highlighter.",
        "examples": [
            {
                "description": "Highlight file syntax and print to `stdout` (language is inferred from the file extension)",
                "command": "pygmentize {{file.py}}"
            },
            {
                "description": "Explicitly set the language for syntax highlighting",
                "command": "pygmentize -l {{javascript}} {{input_file}}"
            },
            {
                "description": "List available lexers (processors for input languages)",
                "command": "pygmentize -L lexers"
            },
            {
                "description": "Save output to a file in HTML format",
                "command": "pygmentize -f html -o {{output_file.html}} {{input_file.py}}"
            },
            {
                "description": "List available output formats",
                "command": "pygmentize -L formatters"
            },
            {
                "description": "Output an HTML file, with additional formatter options (full page, with line numbers)",
                "command": "pygmentize -f html -O \"full,linenos=True\" -o {{output_file.html}} {{input_file}}"
            }
        ]
    }
}