Command-Line Flags
lychee is a fast, asynchronous link checker which detects broken URLs and mail addresses in local files and websites. It supports Markdown and HTML and works well with many plain text file formats.
lychee is powered by lychee-lib, the Rust library for link checking.
Usage:
lychee [OPTIONS] [inputs]...Arguments
Section titled “Arguments”[inputs]…
Section titled “[inputs]…”lychee [inputs]...Inputs for link checking (where to get links to check from). These can be:
files (e.g. README.md), file globs (e.g. '~/git/*/README.md'), remote URLs
(e.g. https://example.com/README.md), or standard input (-). Alternatively,
use --files-from to read inputs from a file.
NOTE: Use -- to separate inputs from options that allow multiple arguments.
Options
Section titled “Options”-a, --accept
Section titled “-a, --accept”lychee --accept <ACCEPT>A List of accepted status codes for valid links
The following accept range syntax is supported: [start]..[[=]end]|code. Some valid examples are:
- 200 (accepts the 200 status code only)
- ..204 (accepts any status code < 204)
- ..=204 (accepts any status code <= 204)
- 200..=204 (accepts any status code from 200 to 204 inclusive)
- 200..205 (accepts any status code from 200 to 205 excluding 205, same as 200..=204)
Use “lychee --accept ‘200..=204, 429, 500’
default: 100..=103,200..=299
--archive
Section titled “--archive”lychee --archive <ARCHIVE>Specify the use of a specific web archive. Can be used in combination with --suggest
possible values: wayback
-b, --base-url
Section titled “-b, --base-url”lychee --base-url <BASE_URL>Base URL to use when resolving relative URLs in local files. If specified, relative links in local files are interpreted as being relative to the given base URL.
For example, given a base URL of https://example.com/dir/page, the link a
would resolve to https://example.com/dir/a and the link /b would resolve
to https://example.com/b. This behavior is not affected by the filesystem
path of the file containing these links.
Note that relative URLs without a leading slash become siblings of the base
URL. If, instead, the base URL ended in a slash, the link would become a child
of the base URL. For example, a base URL of https://example.com/dir/page/ and
a link of a would resolve to https://example.com/dir/page/a.
Basically, the base URL option resolves links as if the local files were hosted at the given base URL address.
The provided base URL value must either be a URL (with scheme) or an absolute path.
Note that certain URL schemes cannot be used as a base, e.g., data and mailto.
--base
Section titled “--base”lychee --base <BASE>Deprecated; use --base-url instead
--basic-auth
Section titled “--basic-auth”lychee --basic-auth <BASIC_AUTH>Basic authentication support. E.g. http://example.com username:password
-c, --config
Section titled “-c, --config”lychee --config <CONFIG_FILE>Configuration file to use
default: lychee.toml
--cache
Section titled “--cache”lychee --cacheUse request cache stored on disk at .lycheecache
--cache-exclude-status
Section titled “--cache-exclude-status”lychee --cache-exclude-status <CACHE_EXCLUDE_STATUS>A list of status codes that will be ignored from the cache
The following exclude range syntax is supported: [start]..[[=]end]|code. Some valid examples are:
- 429 (excludes the 429 status code only)
- 500.. (excludes any status code >= 500)
- ..100 (excludes any status code < 100)
- 500..=599 (excludes any status code from 500 to 599 inclusive)
- 500..600 (excludes any status code from 500 to 600 excluding 600, same as 500..=599)
Use “lychee --cache-exclude-status ‘429, 500..502’
--cookie-jar
Section titled “--cookie-jar”lychee --cookie-jar <COOKIE_JAR>Tell lychee to read cookies from the given file. Cookies will be stored in the cookie jar and sent with requests. New cookies will be stored in the cookie jar and existing cookies will be updated.
--default-extension
Section titled “--default-extension”lychee --default-extension <EXTENSION>This is the default file extension that is applied to files without an extension.
This is useful for files without extensions or with unknown extensions. The extension will be used to determine the file type for processing. Examples: --default-extension md, --default-extension html
--dump
Section titled “--dump”lychee --dumpDon’t perform any link checking. Instead, dump all the links extracted from inputs that would be checked
--dump-inputs
Section titled “--dump-inputs”lychee --dump-inputsDon’t perform any link extraction and checking. Instead, dump all input sources from which links would be collected
-E, --exclude-all-private
Section titled “-E, --exclude-all-private”lychee --exclude-all-privateExclude all private IPs from checking.
Equivalent to --exclude-private --exclude-link-local --exclude-loopback
--exclude
Section titled “--exclude”lychee --exclude <EXCLUDE>Exclude URLs and mail addresses from checking. The values are treated as regular expressions
--exclude-file
Section titled “--exclude-file”lychee --exclude-file <EXCLUDE_FILE>Deprecated; use --exclude-path instead
--exclude-link-local
Section titled “--exclude-link-local”lychee --exclude-link-localExclude link-local IP address range from checking
--exclude-loopback
Section titled “--exclude-loopback”lychee --exclude-loopbackExclude loopback IP address range and localhost from checking
--exclude-path
Section titled “--exclude-path”lychee --exclude-path <EXCLUDE_PATH>Exclude paths from getting checked. The values are treated as regular expressions
--exclude-private
Section titled “--exclude-private”lychee --exclude-privateExclude private IP address ranges from checking
--extensions
Section titled “--extensions”lychee --extensions <EXTENSIONS>Test the specified file extensions for URIs when checking files locally.
Multiple extensions can be separated by commas. Note that if you want to check filetypes, which have multiple extensions, e.g. HTML files with both .html and .htm extensions, you need to specify both extensions explicitly.
default: md,mkd,mdx,mdown,mdwn,mkdn,mkdown,markdown,html,htm,txt
-f, --format
Section titled “-f, --format”lychee --format <FORMAT>Output format of final status report
default: compact
possible values: compact, detailed, json, markdown, raw
--fallback-extensions
Section titled “--fallback-extensions”lychee --fallback-extensions <FALLBACK_EXTENSIONS>When checking locally, attempts to locate missing files by trying the given fallback extensions. Multiple extensions can be separated by commas. Extensions will be checked in order of appearance.
Example: --fallback-extensions html,htm,php,asp,aspx,jsp,cgi
Note: This option takes effect on file:// URIs which do not exist and on
file:// URIs pointing to directories which resolve to themself (by the
--index-files logic).
--files-from
Section titled “--files-from”lychee --files-from <PATH>Read input filenames from the given file or stdin (if path is ’-’).
This is useful when you have a large number of inputs that would be cumbersome to specify on the command line directly.
Examples: lychee --files-from list.txt find . -name ‘*.md’ | lychee --files-from - echo ‘README.md’ | lychee --files-from -
File Format: Each line should contain one input (file path, URL, or glob pattern). Lines starting with ’#’ are treated as comments and ignored. Empty lines are also ignored.
--generate
Section titled “--generate”lychee --generate <GENERATE>Generate special output (e.g. the man page) instead of performing link checking
possible values: man
--github-token
Section titled “--github-token”lychee --github-token <GITHUB_TOKEN>GitHub API token to use when checking github.com links, to avoid rate limiting
env: GITHUB_TOKEN
--glob-ignore-case
Section titled “--glob-ignore-case”lychee --glob-ignore-caseIgnore case when expanding filesystem path glob inputs
-h, --help
Section titled “-h, --help”lychee --helpPrint help (see a summary with ‘-h’)
-H, --header
Section titled “-H, --header”lychee --header <HEADER:VALUE>Set custom header for requests
Some websites require custom headers to be passed in order to return valid responses. You can specify custom headers in the format ‘Name: Value’. For example, ‘Accept: text/html’. This is the same format that other tools like curl or wget use. Multiple headers can be specified by using the flag multiple times.
--hidden
Section titled “--hidden”lychee --hiddenDo not skip hidden directories and files
-i, --insecure
Section titled “-i, --insecure”lychee --insecureProceed for server connections considered insecure (invalid TLS)
--include
Section titled “--include”lychee --include <INCLUDE>URLs to check (supports regex). Has preference over all excludes
--include-fragments
Section titled “--include-fragments”lychee --include-fragmentsEnable the checking of fragments in links
--include-mail
Section titled “--include-mail”lychee --include-mailAlso check email addresses
--include-verbatim
Section titled “--include-verbatim”lychee --include-verbatimFind links in verbatim sections like pre- and code blocks
--include-wikilinks
Section titled “--include-wikilinks”lychee --include-wikilinksCheck WikiLinks in Markdown files
--index-files
Section titled “--index-files”lychee --index-files <INDEX_FILES>When checking locally, resolves directory links to a separate index file. The argument is a comma-separated list of index file names to search for. Index names are relative to the link’s directory and attempted in the order given.
If --index-files is specified, then at least one index file must exist in
order for a directory link to be considered valid. Additionally, the special
name . can be used in the list to refer to the directory itself.
If unspecified (the default behavior), index files are disabled and directory links are considered valid as long as the directory exists on disk.
Example 1: --index-files index.html,readme.md looks for index.html or readme.md
and requires that at least one exists.
Example 2: --index-files index.html,. will use index.html if it exists, but
still accept the directory link regardless.
Example 3: --index-files '' will reject all directory links because there are
no valid index files. This will require every link to explicitly name
a file.
Note: This option only takes effect on file:// URIs which exist and point to a directory.
-m, --max-redirects
Section titled “-m, --max-redirects”lychee --max-redirects <MAX_REDIRECTS>Maximum number of allowed redirects
default: 5
--max-cache-age
Section titled “--max-cache-age”lychee --max-cache-age <MAX_CACHE_AGE>Discard all cached requests older than this duration
default: 1d
--max-concurrency
Section titled “--max-concurrency”lychee --max-concurrency <MAX_CONCURRENCY>Maximum number of concurrent network requests
default: 128
--max-retries
Section titled “--max-retries”lychee --max-retries <MAX_RETRIES>Maximum number of retries per request
default: 3
--min-tls
Section titled “--min-tls”lychee --min-tls <MIN_TLS>Minimum accepted TLS Version
possible values: TLSv1_0, TLSv1_1, TLSv1_2, TLSv1_3
--mode
Section titled “--mode”lychee --mode <MODE>Set the output display mode. Determines how results are presented in the terminal
default: color
possible values: plain, color, emoji, task
-n, --no-progress
Section titled “-n, --no-progress”lychee --no-progressDo not show progress bar. This is recommended for non-interactive shells (e.g. for continuous integration)
--no-ignore
Section titled “--no-ignore”lychee --no-ignoreDo not skip files that would otherwise be ignored by ‘.gitignore’, ‘.ignore’, or the global ignore file
-o, --output
Section titled “-o, --output”lychee --output <OUTPUT>Output file of status report
--offline
Section titled “--offline”lychee --offlineOnly check local files and block network requests
-q, --quiet…
Section titled “-q, --quiet…”lychee --quiet...Less output per occurrence (e.g. -q or -qq)
-r, --retry-wait-time
Section titled “-r, --retry-wait-time”lychee --retry-wait-time <RETRY_WAIT_TIME>Minimum wait time in seconds between retries of failed requests
default: 1
--remap
Section titled “--remap”lychee --remap <REMAP>Remap URI matching pattern to different URI
--require-https
Section titled “--require-https”lychee --require-httpsWhen HTTPS is available, treat HTTP links as errors
--root-dir
Section titled “--root-dir”lychee --root-dir <ROOT_DIR>Root directory to use when checking absolute links in local files. This option is
required if absolute links appear in local files, otherwise those links will be
flagged as errors. This must be an absolute path (i.e., one beginning with /).
If specified, absolute links in local files are resolved by prefixing the given
root directory to the requested absolute link. For example, with a root-dir of
/root/dir, a link to /page.html would be resolved to /root/dir/page.html.
This option can be specified alongside --base-url. If both are given, an
absolute link is resolved by constructing a URL from three parts: the domain
name specified in --base-url, followed by the --root-dir directory path,
followed by the absolute link’s own path.
-s, --scheme
Section titled “-s, --scheme”lychee --scheme <SCHEME>Only test links with the given schemes (e.g. https). Omit to check links with any other scheme. At the moment, we support http, https, file, and mailto.
--skip-missing
Section titled “--skip-missing”lychee --skip-missingSkip missing input files (default is to error if they don’t exist)
--suggest
Section titled “--suggest”lychee --suggestSuggest link replacements for broken links, using a web archive. The web archive can be specified with --archive
-t, --timeout
Section titled “-t, --timeout”lychee --timeout <TIMEOUT>Website timeout in seconds from connect to response finished
default: 20
-T, --threads
Section titled “-T, --threads”lychee --threads <THREADS>Number of threads to utilize. Defaults to number of cores available to the system
-u, --user-agent
Section titled “-u, --user-agent”lychee --user-agent <USER_AGENT>User agent
default: lychee/0.20.1
-v, --verbose…
Section titled “-v, --verbose…”lychee --verbose...Set verbosity level; more output per occurrence (e.g. -v or -vv)
-V, --version
Section titled “-V, --version”lychee --versionPrint version
-X, --method
Section titled “-X, --method”lychee --method <METHOD>Request method
default: get
Repeating Options
Section titled “Repeating Options”Some options can be specified multiple times. This is true for:
--exclude--exclude-path--header--include--remap--scheme
Here is an example:
lychee --exclude https://example.com --exclude https://example.org README.mdTo specify multiple values in this way, the argument flag should be repeated. Otherwise, the extra values would be treated as link checking inputs.