DEV Community

eimza
eimza

Posted on

Reverse Engineering UYAP's .udf File Format: What's Inside a Turkish Court Document?

If you've ever worked with Turkey's national judiciary system (UYAP), you've encountered .udf files — the proprietary document format used for legal petitions, court orders, and official filings. But what actually is a .udf file?

TL;DR

A .udf file is a ZIP archive containing a single content.xml file that follows a custom XML schema (not ODF, not OOXML — something entirely unique to UYAP).

Dissecting the ZIP Layer

const zip = await JSZip.loadAsync(arrayBuffer);
zip.forEach((path, entry) => {
    console.log(path, entry.dir ? 'DIR' : `${entry._data.uncompressedSize} bytes`);
});
// Output: content.xml  4821 bytes
Enter fullscreen mode Exit fullscreen mode

Most .udf files contain just one file: content.xml. Some newer variants may include embedded images (PNG/JPG) alongside it.

The XML Schema

The root element is <template> with a format_id attribute (typically "1.8"):

<?xml version="1.0" encoding="UTF-8"?>
<template format_id="1.8">
  <properties>
    <pageFormat leftMargin="70.86" rightMargin="70.86"
                topMargin="70.86" bottomMargin="70.86"/>
  </properties>
  <elements>
    <paragraph alignment="3">
      <content fontName="Times New Roman" fontSize="12"
               bold="true">DILEKÇE</content>
    </paragraph>
  </elements>
</template>
Enter fullscreen mode Exit fullscreen mode

Key observations:

Element Purpose
<template format_id="1.8"> Root container, versioned
<properties> Page margins in points (1 point ≈ 0.353mm)
<elements> Ordered list of paragraphs and tables
<paragraph alignment="N"> Text block (0=left, 1=right, 2=center, 3=justify)
<content> Text run with inline formatting attributes
<table> → <row> → <cell> Table structure

The <content> Element

Each <content> element is a "text run" — a span of text sharing the same formatting:

<content fontName="Times New Roman" fontSize="12"
         bold="true" italic="false" underline="false"
         foreground="-16777216">Saygılarımızla</content>
Enter fullscreen mode Exit fullscreen mode

The foreground attribute uses Java's Color.getRGB() integer encoding:

  • -16777216 = 0xFF000000 = black (alpha + RGB)
  • To extract hex color: (num >>> 0).toString(16).slice(2)

Why This Matters for AI

None of the major LLMs (GPT-4, Claude, Gemini) can parse .udf files natively. Converting to Markdown preserves the semantic structure while making it universally readable:

**DILEKÇE** → ## DILEKÇE (heading detection via font size)
bold="true" → **text**
italic="true" → *text*
<table> → | col1 | col2 |
Enter fullscreen mode Exit fullscreen mode

Open Source

We built udf2md — a 100% client-side converter. No data leaves your browser. Check it out!

Top comments (0)