Skip to content


Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?


Failed to load latest commit information.
Latest commit message
Commit time
December 17, 2022 05:44
July 30, 2022 10:02
October 30, 2022 06:47
December 23, 2022 07:09
September 30, 2022 06:11
March 16, 2023 07:48
March 16, 2023 07:48
September 30, 2022 06:19
July 30, 2022 10:10
March 3, 2023 06:55
November 28, 2018 16:30



This Python package is for creating and modifying DXF documents, regardless of the DXF version. The package supports loading and rewriting DXF file without losing any content except comments. Unknown DXF tags in the document are ignored but kept for rewriting. This behavior allows processing DXF documents that contain data from third-party applications without loosing information.


  • ezdxf is a Python package to create new DXF files and read/modify/write existing DXF documents
  • MIT-License
  • the intended audience are programmers
  • requires at least Python 3.7
  • OS independent
  • tested with CPython and pypy3
  • has type annotations and passes mypy --ignore-missing-imports -p ezdxf successful
  • additional required packages for the core package without add-ons: typing_extensions, pyparsing
  • read/write/new support for DXF versions: R12, R2000, R2004, R2007, R2010, R2013 and R2018
  • additional read-only support for DXF versions R13/R14 (upgraded to R2000)
  • additional read-only support for older DXF versions than R12 (upgraded to R12)
  • read/write support for ASCII DXF and Binary DXF
  • retains third-party DXF content
  • optional C-extensions for CPython are included in the binary wheels, available on PyPI for Windows, Linux and macOS

Included Extensions

Additional packages required for these add-ons are not automatically installed during the basic setup, for more information about the setup & dependencies visit the documentation.

  • The drawing add-on is a translation layer to send DXF data to a render backend, interfaces to matplotlib, which can export images as PNG, PDF or SVG, and PyQt5 are implemented.
  • r12writer add-on to write basic DXF entities direct and fast into a DXF R12 file or stream
  • iterdxf add-on to iterate over DXF entities from the modelspace of huge DXF files (> 5GB) which do not fit into memory
  • Importer add-on to import entities, blocks and table entries from another DXF document
  • dxf2code add-on to generate Python code for DXF structures loaded from DXF documents as starting point for parametric DXF entity creation
  • acadctb add-on to read/write plot style files (CTB/STB)
  • pycsg add-on for basic Constructive Solid Geometry (CSG) modeling
  • MTextExplode add-on for exploding MTEXT entities into single-line TEXT entities
  • text2path add-on to convert text into outline paths
  • geo add-on to support the __geo_interface__
  • meshex for exchanging meshes with other tools as STL, OFF or OBJ files
  • openscad add-on, an interface to OpenSCAD
  • odafc add-on, an interface to the ODA File Converter to read and write DWG files

A simple example:

import ezdxf
from ezdxf import colors
from ezdxf.enums import TextEntityAlignment

# Create a new DXF document.
doc ="R2010")

# Create new table entries (layers, linetypes, text styles, ...).
doc.layers.add("TEXTLAYER", color=colors.RED)

# DXF entities (LINE, TEXT, ...) reside in a layout (modelspace, 
# paperspace layout or block definition).  
msp = doc.modelspace()

# Add entities to a layout by factory methods: layout.add_...() 
msp.add_line((0, 0), (10, 0), dxfattribs={"color": colors.YELLOW})
        "layer": "TEXTLAYER"
    }).set_placement((0, 0.2), align=TextEntityAlignment.CENTER)

# Save the DXF document.

Example for the r12writer, which writes a simple DXF R12 file without in-memory structures:

from random import random
from ezdxf.addons import r12writer

MAX_X_COORD = 1000
MAX_Y_COORD = 1000

with r12writer("many_circles.dxf") as doc:
    for _ in range(100000):
        doc.add_circle((MAX_X_COORD*random(), MAX_Y_COORD*random()), radius=2)

The r12writer supports only the ENTITIES section of a DXF R12 drawing, no HEADER, TABLES or BLOCKS section is present, except FIXED-TABLES are written, than some additional predefined text styles and line types are available.


Basic installation by pip including the optional C-extensions from PyPI as binary wheels:

pip install ezdxf

Full installation with all dependencies (matplotlib, PySide6) for using the drawing add-on:

pip install ezdxf[draw]

For more information about the setup & dependencies visit the documentation.



Documentation of the development version at

Documentation of the latest release at


The source code of ezdxf can be found at GitHub, target your pull requests to the master branch:


Questions and feedback at GitHub Discussions:

Questions at Stack Overflow:

Post questions at stack overflow and use the tag dxf or ezdxf.

Issue tracker at GitHub:


Please always post questions at the forum or stack overflow to make answers available to other users as well.

Feedback is greatly appreciated.