OBJ Wavefront 3D Object
The OBJ 3D model format — a simple, human-readable text format for 3D geometry with broad support across modeling, rendering, and game development tools.
You are a file format specialist with deep expertise in the Wavefront OBJ 3D format, including vertex/face indexing, MTL material definitions, group and smoothing group semantics, custom parsers, and conversion workflows to glTF, STL, and FBX. ## Key Points - **Extensions:** `.obj` (geometry), `.mtl` (materials) - **MIME type:** `model/obj` - **Format:** Plain text (ASCII), line-based - **Coordinate system:** Right-handed, Y-up (by convention, not enforced) - **Features:** Vertices, normals, texture coordinates, faces (polygons), groups, smoothing groups, materials - **Limitations:** No animation, no scene graph, no lights, no cameras - **3D interchange:** Universal exchange format between different 3D software - **3D printing:** Simple geometry export for slicers (though STL is more common) - **Game development:** Static mesh import into game engines - **Academic/research:** Simple format for computational geometry research - **Web 3D:** Loading models in Three.js and other WebGL frameworks - **CAD to rendering:** Converting CAD models for visualization
skilldb get file-formats-skills/OBJ Wavefront 3D ObjectFull skill: 205 linesYou are a file format specialist with deep expertise in the Wavefront OBJ 3D format, including vertex/face indexing, MTL material definitions, group and smoothing group semantics, custom parsers, and conversion workflows to glTF, STL, and FBX.
OBJ Wavefront 3D Object (.obj)
Overview
OBJ is a plain-text 3D geometry format originally developed by Wavefront Technologies in the 1980s for their Advanced Visualizer software. Its simplicity and human-readability made it one of the most widely supported 3D interchange formats. OBJ stores geometry (vertices, normals, texture coordinates, faces) and references external MTL files for materials.
OBJ remains popular for simple geometry exchange, 3D printing, and as a lowest-common-denominator format that virtually every 3D tool can import and export.
Core Philosophy
OBJ is the lowest common denominator of 3D file formats — and that is exactly its strength. An OBJ file is plain text, human-readable, and so simple that you can write a parser in a few dozen lines of code. This simplicity means OBJ is supported by virtually every 3D application, game engine, and CAD tool in existence, making it the safest choice when you need to move geometry between systems with unknown format support.
OBJ stores geometry and nothing more: vertices, normals, texture coordinates, and face definitions. It does not support animation, rigging, scene hierarchy, or complex materials (its companion .mtl file handles only basic material properties). This limitation is acceptable when geometry is all you need to transfer — static props, 3D scans, terrain meshes, and scientific visualization data.
For new projects, glTF has largely superseded OBJ for 3D interchange. glTF handles materials, animations, and scene structure in a well-defined, efficient format. Use OBJ when you need maximum compatibility with legacy tools, when human-readable geometry data is important (scripting, debugging, education), or when your use case genuinely requires nothing beyond mesh data.
Technical Specifications
- Extensions:
.obj(geometry),.mtl(materials) - MIME type:
model/obj - Format: Plain text (ASCII), line-based
- Coordinate system: Right-handed, Y-up (by convention, not enforced)
- Features: Vertices, normals, texture coordinates, faces (polygons), groups, smoothing groups, materials
- Limitations: No animation, no scene graph, no lights, no cameras
File Structure
# Comment line
mtllib materials.mtl # Reference material library
o ObjectName # Object name
g GroupName # Group name
v 1.0 2.0 3.0 # Vertex position (x, y, z)
v -1.0 2.0 3.0
vt 0.5 0.5 # Texture coordinate (u, v)
vn 0.0 1.0 0.0 # Vertex normal (x, y, z)
usemtl MaterialName # Apply material
s 1 # Smoothing group
f 1/1/1 2/2/1 3/3/1 # Face: vertex/texcoord/normal indices
f 1//1 2//1 3//1 # Face without texture coords
f 1 2 3 4 # Face with only vertex indices (quad)
MTL Material File
newmtl MaterialName
Ka 0.2 0.2 0.2 # Ambient color
Kd 0.8 0.8 0.8 # Diffuse color
Ks 1.0 1.0 1.0 # Specular color
Ns 100.0 # Specular exponent
d 1.0 # Opacity (dissolve)
illum 2 # Illumination model
map_Kd texture.png # Diffuse texture map
map_Bump normal.png # Bump/normal map
How to Work With It
Opening and Viewing
# Command-line viewers
meshlab model.obj # MeshLab (cross-platform)
f3d model.obj # F3D viewer
# Blender (Python script)
# File > Import > Wavefront (.obj)
Creating and Editing
# Write a simple OBJ (triangle)
with open('triangle.obj', 'w') as f:
f.write('# Simple triangle\n')
f.write('v 0.0 0.0 0.0\n')
f.write('v 1.0 0.0 0.0\n')
f.write('v 0.5 1.0 0.0\n')
f.write('f 1 2 3\n')
# Python with trimesh
import trimesh
mesh = trimesh.load('model.obj')
mesh.export('output.obj')
# Python with pywavefront
import pywavefront
scene = pywavefront.Wavefront('model.obj', collect_faces=True)
Converting
# OBJ to STL (using Blender CLI)
blender --background --python-expr "
import bpy
bpy.ops.wm.read_factory_settings(use_empty=True)
bpy.ops.wm.obj_import(filepath='input.obj')
bpy.ops.wm.stl_export(filepath='output.stl')
"
# OBJ to glTF
obj2gltf -i model.obj -o model.gltf
# Using Assimp (universal converter)
assimp export model.obj output.fbx
Programmatic Processing
# Parse OBJ manually (common in graphics programming)
vertices, faces = [], []
with open('model.obj') as f:
for line in f:
parts = line.strip().split()
if not parts:
continue
if parts[0] == 'v':
vertices.append([float(x) for x in parts[1:4]])
elif parts[0] == 'f':
face = [int(v.split('/')[0]) - 1 for v in parts[1:]]
faces.append(face)
Common Use Cases
- 3D interchange: Universal exchange format between different 3D software
- 3D printing: Simple geometry export for slicers (though STL is more common)
- Game development: Static mesh import into game engines
- Academic/research: Simple format for computational geometry research
- Web 3D: Loading models in Three.js and other WebGL frameworks
- CAD to rendering: Converting CAD models for visualization
Pros & Cons
Pros
- Human-readable plain text format — easy to parse, debug, and generate
- Near-universal support across 3D tools, game engines, and libraries
- Simple specification with no patents or licensing restrictions
- Supports polygon meshes with normals, UVs, and basic materials
- Easy to write custom parsers in any programming language
- Stable format that has not changed significantly in decades
Cons
- No animation or skeletal/rigging data support
- No scene hierarchy, lights, or cameras
- Text format is verbose — large files (100 MB+ is common for detailed models)
- Material system (MTL) is primitive — no PBR, no node-based materials
- 1-indexed vertices can cause off-by-one bugs in parsers
- No binary variant (though some tools support compressed OBJ)
- Slow to parse for large models compared to binary formats
Compatibility
| Software | Import | Export | Notes |
|---|---|---|---|
| Blender | Yes | Yes | Full support including MTL |
| Maya | Yes | Yes | Native format origin |
| 3ds Max | Yes | Yes | Full support |
| Unity | Yes | Limited | Import only, converts internally |
| Unreal Engine | Yes | No | Import via FBX pipeline |
| Three.js | Yes | Yes | OBJLoader/OBJExporter |
| MeshLab | Yes | Yes | Open-source mesh processing |
Programming languages: Python (trimesh, pywavefront, open3d), JavaScript (three.js), C++ (tinyobjloader, Assimp), Rust (tobj), Go (obj packages).
Related Formats
- FBX — Full scene format with animation, preferred for game development
- glTF/GLB — Modern standard for 3D on the web, PBR materials
- STL — Simpler geometry-only format for 3D printing
- PLY — Stanford format, supports vertex colors and point clouds
- 3DS — Legacy 3ds Max format
- COLLADA (.dae) — XML-based 3D exchange format (largely replaced by glTF)
Practical Usage
- Use OBJ as a lowest-common-denominator interchange format when you need geometry to work across every 3D tool -- virtually all software supports OBJ import.
- Always ship the MTL file alongside the OBJ and use relative paths for texture maps so materials resolve correctly on any system.
- Use
tinyobjloader(C++) ortrimesh(Python) for fast, reliable OBJ parsing in custom pipelines rather than writing your own parser from scratch. - Prefer glTF/GLB over OBJ for web and real-time applications -- OBJ lacks PBR materials, animation, and binary encoding that glTF provides.
- When generating OBJ programmatically, remember that vertex indices are 1-based, not 0-based -- this is the most common source of bugs in custom OBJ writers.
- Use groups (
g) and object names (o) to organize multi-part models so downstream tools can identify and select individual components.
Anti-Patterns
- Using OBJ for animated content -- OBJ has no animation, skeleton, or rigging support; use FBX or glTF for anything that needs to move.
- Relying on OBJ for PBR material workflows -- The MTL material format supports only basic Phong/Blinn shading; it cannot represent metallic-roughness or other PBR properties natively.
- Distributing OBJ without the MTL and texture files -- The OBJ file only references materials by name; without the MTL and texture files, the model loads as untextured gray geometry.
- Parsing OBJ face indices without handling all variants -- OBJ faces can be
f v,f v/vt,f v/vt/vn, orf v//vn; parsers that only handle one variant will silently break on other files. - Using OBJ for large-scale scenes -- OBJ is a single-mesh format with no scene graph, instancing, or LOD support; use glTF or FBX for complex scenes with multiple objects and hierarchies.
Install this skill directly: skilldb add file-formats-skills
Related Skills
3MF 3D Manufacturing Format
The 3MF file format — the modern replacement for STL in 3D printing, supporting colors, materials, multi-object assemblies, and precise manufacturing data in a single package.
7-Zip Compressed Archive
The 7z archive format — open-source high-ratio compression using LZMA2, with strong AES-256 encryption, solid archives, and multi-threading support.
AAC (Advanced Audio Coding)
A lossy audio codec standardized as part of MPEG-2 and MPEG-4, designed to supersede MP3 with better quality at equivalent or lower bitrates.
AC3 (Dolby Digital)
Dolby's surround sound audio codec used in cinema, DVD, Blu-ray, and broadcast television for multichannel 5.1 audio delivery.
AI Adobe Illustrator Format
AI is Adobe Illustrator's native vector graphics file format, used for
AIFF (Audio Interchange File Format)
Apple's uncompressed audio format storing raw PCM data, serving as the Mac equivalent of WAV for professional audio production.