What is a .tex file?
LaTeX Source Document · Document · Donald Knuth / Leslie Lamport · 1978
A .tex file is a LaTeX or TeX source document: plain text marked up with commands that a TeX engine typesets into a beautifully formatted PDF. It is the standard for academic papers, maths and books.
What is a .tex file used for?
Instead of a visual editor, LaTeX describes structure and maths in text commands, then compiles to PDF. This gives precise, consistent typography, which is why journals and mathematicians rely on it.
The files are plain text and open in any editor, but you need a TeX distribution (TeX Live, MiKTeX) or an online service like Overleaf to compile them into a document.
How to open a .tex file
The .tex format opens in the following apps, grouped by operating system. If one app does not work, try another from the same list. For a step-by-step walkthrough, see how to open a .tex file.
Windows
- TeXworks
- VS Code (LaTeX Workshop)
- MiKTeX
macOS
- TeXShop
- VS Code
- MacTeX
Linux
- TeX Live
- VS Code
- any text editor
Web
- Overleaf
How to convert a .tex file
You can convert a .tex file to pdf, html, docx using a conversion tool or the export menu of an app that opens it.
.tex file signature (magic bytes)
Programs recognise a .tex file by the bytes at the start of the file, not by its name. These are the signatures for TeX.
| Hex signature | Offset | Note |
|---|---|---|
| (no fixed signature) | 0 | plain text; no fixed magic bytes |
See the full magic-numbers reference for every format.
Frequently asked questions
What is a .tex file?
A .tex file is a LaTeX or TeX source document: plain text marked up with commands that a TeX engine typesets into a beautifully formatted PDF. It is the standard for academic papers, maths and books.
How do I open a .tex file?
Any text editor shows the source. To produce the formatted document, compile it with a TeX distribution such as TeX Live or MiKTeX, or use Overleaf online.
How do I turn a .tex file into a PDF?
Run a LaTeX compiler (pdflatex file.tex), use an editor like TeXworks or VS Code with LaTeX Workshop, or upload it to Overleaf.
What is the difference between TeX and LaTeX?
TeX is the low-level typesetting engine; LaTeX is a widely used set of macros on top of it. Most .tex files people write today are LaTeX.
Related formats
Sources
Details on this page were checked against authoritative references: