OBJ to JSON Converter
Convert Wavefront .OBJ 3D model files to structured JSON format online. Supports vertices, normals, texture coords, and triangulated faces for WebGL.
About
Wavefront OBJ is a plain-text geometry format dating to the 1980s. Its simplicity makes it ubiquitous but its lack of native browser support creates friction in WebGL pipelines. Manually parsing vertex positions (v), texture coordinates (vt), and face index triplets (f) is error-prone. Mismatched index bases (OBJ uses 1-based indexing; WebGL expects 0-based) cause silent rendering failures: missing triangles, inverted normals, black textures. This converter parses OBJ files client-side with correct index rebasing, fan triangulation of n-gon faces, and outputs a structured JSON object ready for gl.bufferData(). No server upload required. The tool approximates the OBJ specification for polygonal geometry; it does not handle free-form curves, material libraries (.mtl), or group hierarchies.
Formulas
OBJ face indices are 1-based. WebGL and most JSON consumers expect 0-based indexing. The rebasing operation for each index i is:
For negative indices (relative references from end of current list of length n):
N-gon faces with k vertices (where k > 3) are triangulated via fan decomposition, producing k − 2 triangles. For vertices [v0, v1, …, vk−1], triangle j is:
Where v0 is the pivot vertex, k is the face vertex count, and Tj represents the j-th output triangle.
Reference Data
| OBJ Prefix | Data Type | Components | JSON Key | Example Line |
|---|---|---|---|---|
v | Vertex Position | x, y, z | vertices | v 1.0 2.0 3.0 |
vt | Texture Coordinate | u, v | texcoords | vt 0.5 0.8 |
vn | Vertex Normal | x, y, z | normals | vn 0.0 1.0 0.0 |
f | Face (tri/quad/n-gon) | v/vt/vn indices | faces | f 1/1/1 2/2/1 3/3/1 |
f | Face (pos only) | v indices | faces | f 1 2 3 |
f | Face (pos+normal) | v//vn indices | faces | f 1//1 2//1 3//1 |
f | Face (pos+tex) | v/vt indices | faces | f 1/1 2/2 3/3 |
# | Comment | - | Ignored | # cube mesh |
o | Object Name | string | name | o MyCube |
g | Group Name | string | Ignored | g front |
s | Smooth Shading | on/off/int | Ignored | s 1 |
mtllib | Material Library | filename | Ignored | mtllib cube.mtl |
usemtl | Material Usage | name | Ignored | usemtl wood |