GenericAutoCADdrawing file
image/vnd.dwg
Magic Bytes
Offset: 0
4D 43 30 2E 30
The DWG format is a proprietary binary file structure developed and maintained by Autodesk for storing two-dimensional and three-dimensional design data. It serves as the native data container for AutoCAD and is utilized by engineers and architects for technical blueprints and three-dimensional modeling. Although this specific signature identifies early legacy versions from 1982, modern iterations remain the industry standard for exchanging complex, high-precision computer-aided design information across global drafting platforms.
Validation Code
How to validate .dwg files in Python
Python
def is_dwg(file_path: str) -> bool:
"""Check if file is a valid DWG by magic bytes."""
signature = bytes([0x4D, 0x43, 0x30, 0x2E, 0x30])
with open(file_path, "rb") as f:
return f.read(5) == signature
How to validate .dwg files in Node.js
Node.js
function isDWG(buffer: Buffer): boolean {
const signature = Buffer.from([0x4D, 0x43, 0x30, 0x2E, 0x30]);
return buffer.subarray(0, 5).equals(signature);
}
Go
func IsDWG(data []byte) bool {
signature := []byte{0x4D, 0x43, 0x30, 0x2E, 0x30}
if len(data) < 5 {
return false
}
return bytes.Equal(data[:5], signature)
}
API Endpoint
GET
/api/v1/dwg
curl https://filesignature.org/api/v1/dwg