Info
This site is generated using the static site generator developed by the Typst Community. Please adjust the text content of this banner according to your usage requirements. At Typst GmbH's request, when publishing documentation, you must clearly indicate that it is non-official and display the version of Typst being documented. For details, refer to Issue #874 on typst/typst.
TypstDocumentEnglish
v0.dev.2025-09-12

read

Reads plain text or data from a file.

By default, the file will be read as UTF-8 and returned as a string.

If you specify encoding: none, this returns raw bytes instead.

Example

An example for a HTML file: \
#let text = read("example.html")
#raw(text, lang: "html")

Raw bytes:
#read("tiger.jpg", encoding: none)
Preview

Parameter
Parameter
Parameters are input values for functions. Specify them in parentheses after the function name.

path
Required
Required
Required parameters must be specified when calling the function.
Positional
Positional
Positional parameters can be set by specifying them in order, omitting the parameter name.

Path to a file.

For more details, see the Paths section.

encoding

The encoding to read the file with.

If set to none, this function returns raw bytes.

Available string values:
  • utf8

    The Unicode UTF-8 encoding.

Default value:

"utf8"

Open official docs

Search