For the complete Mojo documentation index, see llms.txt. Markdown versions of all pages are available by appending .md to any URL (e.g. /docs/manual/basics.md).
Mojo language reference
Welcome to the Mojo language reference. This documentation provides a concise reference for Mojo's syntax—identifiers, keywords, literals, expressions, operators, statements, function declarations, and more. It's organized by grammar construct and designed for quick lookup when you need the exact rules, precedence, or form of a specific language element.
Identifiers & keywords
Naming rules, reserved words, escaped identifiers, and argument conventions
Literals
Integer, floating-point, string, t-string, boolean, None, and Self literals
Numeric types
SIMD, DType, Scalar, Int, UInt, integers, floating-point, Byte, literals, and conversions
Operators
Operator precedence, associativity, and implementing operators for custom types
Expressions
Tuples, collection displays, member access, calls, subscripts, ternary conditionals, and comprehensions
Simple statements
Imports, assignments, return, raise, break, continue, and compile-time declarations
Compound statements
If statements, loops, error handling with try/except, context managers, and compile-time control flow
Function declarations
Signatures, parameters, arguments, default values, constraints, effects, and special methods
Struct declarations
Fields, methods, initializers, destructors, and trait conformance for structs
Trait declarations
Required and provided methods, associated types, trait inheritance, trait composition, and conformance
Inline MLIR
Inline MLIR built-ins can call operations that the language doesn't expose natively.
Decorators
Modify or extend the behavior of a struct, function, or other declaration at compile time.
Learning Mojo? There's more to explore outside the Mojo Language Reference.
The Mojo manual
A comprehensive guide to the Mojo programming language
Standard library
Core types and functions for all Mojo programs
Layout library
Abstractions for working with multidimensional data
Code examples
Browse a wide range of Mojo code examples on GitHub
Community
Chat with us and the community in our forum and Discord channels
Releases
Find Mojo releases and changelogs.