.DTD

DTD File

Document Type Definition
Ask a question
QUICK ANSWER

A DTD file is a Document Type Definition - a plain-text schema that specifies the allowed elements, attributes, and nesting rules for XML or SGML documents. Open it in any text editor (Notepad++, VS Code) or a dedicated XML editor like Oxygen XML Editor. DTDs have been largely replaced by XSD for new XML projects, but remain common in DocBook, DITA, and SGML-based publishing systems.

Developer: W3C / ISO (SGML origin: ISO 8879:1986; XML DTD defined in W3C XML 1.0 spec, 1998) Category: Developer Files Open standard MIME: application/xml-dtd
OPENS ON Windows macOS Linux
Related: .DO · .MD · .HEX · .XSD

On this page

19k+ extensions indexed
Last reviewed Aug 15, 2026

Not sure what your file is?

Drop any file into our identifier - we read just the first bytes to name the format.

Identify a file

What is the DTD file format?

DTD stands for Document Type Definition. A .dtd file is a plain text file that defines the permitted elements, attributes, and structure of an XML, XHTML, HTML, or SGML document.

The data saved in a DTD file describes the structure of its associated document - including allowed nesting and ordering of elements. DTD files ensure consistency when documents are exchanged between systems; a validating XML parser can also check the validity of a specific document against its DTD. Declarations use three main types: <!ELEMENT> (child elements), <!ATTLIST> (attributes), and <!ENTITY> (reusable text macros).

DTDs originated with the SGML standard (ISO 8879, 1986) and were adopted by the W3C XML 1.0 specification in 1998. Well-known public DTDs cover XHTML, DocBook, SVG, and MathML. Because DTDs lack XML namespace support and rich data types, XSD (W3C XML Schema) and RELAX NG are now the preferred alternatives. HTML5 uses a minimal <!DOCTYPE html> declaration that does not reference an actual DTD file.

Security & safety

RISK: LOW

Plain text file; no executable content. DTD external entity declarations (<!ENTITY % name SYSTEM 'url'>) can cause XML External Entity (XXE) attacks when processed by XML parsers in application code - not a risk from opening the DTD file itself, but a risk when the DTD is used in an application that parses untrusted XML with DTD processing enabled. Safe to open in a text editor.

Format details

in a nutshell
FULL NAMEDocument Type Definitionaka DTD file, XML DTD
DEVELOPERW3C / ISO (SGML origin: ISO 8879:1986; XML DTD defined in W3C XML 1.0 spec, 1998)since 1986 (SGML, ISO 8879); 1998 for XML DTD (W3C XML 1.0 Recommendation, February 1998)
MIME TYPEapplication/xml-dtd
TYPEPlain text schema/declaration file
STANDARDOpen · royalty-free

Programs that open DTD files

Windows7 apps
Microsoft Visual Studio Freemium Opens .dtd as XML text with syntax highlighting. Limited DTD-specific tooling.
Windows Notepad Built-in Opens as plain text; no syntax highlighting. Adequate for quick viewing.
oXygen XML Editor Paid Full DTD authoring with validation, content completion, and documentation generation. File > Open.
Notepad Open-source Open directly; configure language as XML for syntax highlighting. All DTD declarations are human-readable.
Visual Studio Code Open-source Open directly; install 'XML' extension (Red Hat) for DTD syntax highlighting and validation.
Altova XMLSpy Paid Professional DTD editor with graphical element view and DTD/XSD generation. File > Open.
Eclipse (with XML tools) Open-source Install Eclipse XML Editors and Tools plugin (WTP); provides DTD editing with validation.
macOS3 apps
TextMate Open-source Open directly with XML bundle for syntax highlighting.
oXygen XML Editor Paid Full DTD authoring support on macOS.
Visual Studio Code Open-source Install Red Hat XML extension for DTD support.
Linux2 apps
oXygen XML Editor Paid Linux version available; full DTD support.
Visual Studio Code Open-source Install Red Hat XML extension.

Technical details

deep spec
File typePlain text schema/declaration file
MIME typeapplication/xml-dtd; text/plain (alternate)
Magic bytesNone - plain text (may begin with an XML comment or directly with a <!ELEMENT declaration)
EncodingUTF-8 or US-ASCII; encoding declared in optional leading XML processing instruction
CompressionNone - uncompressed plain text
Typical size1 KB - 500 KB (simple DTDs are small; complex standards like DITA or DocBook DTDs can be 100+ KB with modular .mod/.ent files)
Declaration types<!ELEMENT> (child elements and content model), <!ATTLIST> (attributes and defaults), <!ENTITY> (text macros), <!NOTATION> (notation types)
Standard originSGML ISO 8879 (October 1986); adopted by W3C XML 1.0 Recommendation (February 1998)
Namespace supportNone - DTD syntax predates XML namespaces, a key limitation versus XSD
Data type supportLimited to ID, IDREF, CDATA, NMTOKEN, and a few others - no rich types such as date or integer
ValidationXML parsers can validate a document against its DTD using ELEMENT and ATTLIST constraints
HTML5 DOCTYPE<!DOCTYPE html> is a minimal stub; does not reference or require an actual DTD file
Well-known public DTDsXHTML 1.0, DocBook, DITA, SVG 1.1, MathML 2.0 - referenced by PUBLIC/SYSTEM identifiers in documents
Superseded byW3C XML Schema (.xsd, 2001) and RELAX NG (.rnc/.rng, 2003) for namespace-aware and richly-typed validation
Released1986 (SGML, ISO 8879); 1998 for XML DTD (W3C XML 1.0 Recommendation, February 1998)
Latest versionXML 1.0 Fifth Edition (November 2008); XML 1.1 Second Edition (August 2006) - DTD syntax unchanged since 1998; W3C XML Schema (XSD) and RELAX NG are modern replacements
Open standardYes · royalty-free
Specificationwww.w3.org

DTD conversions

Community Q&A

asked by users
Ask a quick question
Get help from people who work with DTD files. Be specific - include your system and software version.
No account needed · answers usually within a day

No questions yet - be the first to ask about DTD files.

Frequently asked questions

What is a DTD file used for?
A DTD defines the legal structure of an XML or SGML document - which elements are allowed, in what order, and what attributes they can have. XML parsers use DTDs to validate that a document is structurally correct.
Should I use DTD or XSD for a new project?
Use XSD (XML Schema, .xsd) for new projects - it supports namespaces, data types (dates, numbers, patterns), and is far more expressive. DTDs are appropriate only for SGML systems or compatibility with legacy tools.
How do I validate an XML file against a DTD?
Reference the DTD in the XML file's DOCTYPE declaration, then use an XML validator. In Oxygen XML Editor or XMLSpy use Document > Validate. Command line: xmllint --valid --noout file.xml.
What is the difference between DTD and XSD?
DTD (older): simple, no namespace support, only token data types, SGML/XML native. XSD (newer, 2001): supports namespaces, rich data types (string, integer, date, regex patterns), inheritance, and more complex validation rules.
Can I open a DTD file in a web browser?
Yes - modern browsers display XML/DTD as formatted text. Firefox and Chrome show XML source with syntax highlighting when you open a .dtd file.
What is the DOCTYPE declaration in HTML?
<!DOCTYPE html> in HTML5 is a minimal declaration that switches browsers into standards mode; it does not reference a .dtd file and no DTD validation occurs in browsers.

References

1W3C Extensible Markup Language (XML) 1.0 Fifth Editionwww.w3.org
2Wikipedia - Document type definitionen.wikipedia.org

Keep exploring

across the database

Top extensions this week

1.AQQAQQ Instant Messenger File
2.BINCD/DVD Disc Image (BIN/CUE)
3.PARTPartial Download File
4.CRDOWNLOADChrome Partial Download File
5.RPMSGRestricted Permission Message
6.MDMarkdown Document
7.NOMEDIAAndroid No-Media Marker File
8.PRDXSoftMaker Presentations Document
9.PRO6XProPresenter 6 Bundle File
10.SWFSmall Web Format (Shockwave Flash)

Related extensions

.DOStata Do-File
.MDMarkdown Document
.HEXIntel HEX File
.XSDXML Schema Definition
.MAPSource Map (JavaScript / CSS)
.CONFIGConfiguration File

Free file tools

An in-browser file identifier and image converter - everything runs on your device.

Open the toolbox

Browse file extensions A-Z