Vietnamese Legal Text Parser API

Parse Vietnamese legal texts into Phần, Chương, Mục, Điều, Khoản, Điểm; extract number, type, dates, references, amendments; chunk for RAG.

POSThttps://apibox.io.vn/v1/vn-legal-parse

Send a Vietnamese legal or administrative document as plain text (text), HTML (html) or a .docx / .txt file. The parser normalises Unicode to NFC, then builds the tree Phần → Chương → Mục → Tiểu mục → Điều → Khoản → Điểm with numbers, titles and line numbers. Text quoted inside an amending law (“Điều 10. …”) is kept as text, not mistaken for structure.

Metadata from the header: document number split into sequence / year / symbol with the type and issuer decoded (e.g. 123/2020/NĐ-CP → Nghị định, Chính phủ; administrative symbols per NĐ 30/2020 Phụ lục III), legal or administrative kind (the Law on Promulgation of Legal Documents 2025 numbers legal documents as number/year/symbol), issuer, type, title, place and date of issue, "Căn cứ" bases and the effective date found in the text. It also lists references to other documents ("Nghị định số 01/2021/NĐ-CP", "Luật Đầu tư"), article references ("khoản 1 Điều 10 của Luật Đầu tư …") and amendment markers (sửa đổi, bổ sung, bãi bỏ, thay thế…).

For retrieval-augmented generation, chunks cut the text by article (or by clause with chunk_by=clause; long articles are split by clause, then by sentence) under max_chars (or max_tokens), each chunk starting with its breadcrumb "Nghị định 123/2020/NĐ-CP > Chương I > Điều 1. …" so that the embedding keeps the context. Nothing is stored.

Parameters

NameInTypeRequiredDefault
textbodystringnoPlain text of the document (or send html, or a file).
htmlbodystringnoHTML of the document (tags are stripped, blocks become lines).
filebodyfileno.docx or .txt file (multipart).
chunk_bybodystringnoarticlearticle or clause.
max_charsbodynumberno2000Maximum characters per chunk (200–20,000).
max_tokensbodynumbernoAlternative to max_chars (≈ 3 characters per token).
breadcrumbbodybooleannotruePrefix each chunk with its heading path.
outputbodystringnoallall, structure, chunks or metadata.

Example

curl -X POST "https://apibox.io.vn/v1/vn-legal-parse" \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"text":"CHÍNH PHỦ\nSố: 123/2020/NĐ-CP\nHà Nội, ngày 19 tháng 10 năm 2020\nNGHỊ ĐỊNH\nQuy định về hóa đơn, chứng từ\nChương I\nQUY ĐỊNH CHUNG\nĐiều 1. Phạm vi điều chỉnh\n1. Nghị định này quy định việc quản lý, sử dụng hóa đơn khi bán hàng hóa, cung cấp dịch vụ.\n2. Hóa đơn gồm:\na) Hóa đơn điện tử;\nb) Hóa đơn do cơ quan thuế đặt in.\nĐiều 2. Hiệu lực thi hành\nNghị định này có hiệu lực thi hành từ ngày 01 tháng 7 năm 2022 và bãi bỏ khoản 3 Điều 5 Nghị định số 51/2010/NĐ-CP.","max_chars":800}'

Response

{
  "metadata": {
    "number": {
      "number": "123/2020/NĐ-CP",
      "seq": 123,
      "year": 2020,
      "symbol": "NĐ-CP",
      "type": "Nghị định",
      "type_code": "NĐ",
      "issuer_codes": [
        "CP"
      ],
      "issuers": [
        "Chính phủ"
      ],
      "kind": "legal_normative"
    },
    "issued_date": "2020-10-19",
    "place": "Hà Nội",
    "issuer": "CHÍNH PHỦ",
    "type": "Nghị định",
    "title": "Quy định về hóa đơn, chứng từ",
    "effective_date": "2022-07-01",
    "characters": 458
  },
  "stats": {
    "parts": 0,
    "chapters": 1,
    "sections": 0,
    "subsections": 0,
    "articles": 2,
    "clauses": 2,
    "points": 2,
    "references": 1,
    "internal_references": 1,
    "amendment_markers": 1,
    "chunks": 2
  },
  "structure": [
    {
      "type": "chapter",
      "number": "I",
      "title": "QUY ĐỊNH CHUNG",
      "line": 6,
      "path": "Chương I. QUY ĐỊNH CHUNG",
      "children": [
        {
          "type": "article",
          "number": "1",
          "title": "Phạm vi điều chỉnh",
          "line": 8,
          "path": "Chương I. QUY ĐỊNH CHUNG > Điều 1. Phạm vi điều chỉnh",
          "children": [
            {
              "type": "clause",
              "number": "1",
              "text": "Nghị định này quy định việc quản lý, sử dụng hóa đơn khi bán hàng hóa, cung cấp dịch vụ.",
              "line": 9,
              "path": "Chương I. QUY ĐỊNH CHUNG > Điều 1. Phạm vi điều chỉnh > Khoản 1"
            },
            {
              "type": "clause",
              "number": "2",
              "text": "Hóa đơn gồm:",
              "line": 10,
              "path": "Chương I. QUY ĐỊNH CHUNG > Điều 1. Phạm vi điều chỉnh > Khoản 2",
              "children": [
                {
                  "type": "point",
                  "number": "a",
                  "text": "Hóa đơn điện tử;",
                  "line": 11,
                  "path": "Chương I. QUY ĐỊNH CHUNG > Điều 1. Phạm vi điều chỉnh > Khoản 2 > Điểm a"
                },
                {
                  "type": "point",
                  "number": "b",
                  "text": "Hóa đơn do cơ quan thuế đặt in.",
                  "line": 12,
                  "path": "Chương I. QUY ĐỊNH CHUNG > Điều 1. Phạm vi điều chỉnh > Khoản 2 > Điểm b"
                }
              ]
            }
          ]
        },
        {
          "type": "article",
          "number": "2",
          "title": "Hiệu lực thi hành",
          "text": "Nghị định này có hiệu lực thi hành từ ngày 01 tháng 7 năm 2022 và bãi bỏ khoản 3 Điều 5 Nghị định số 51/2010/NĐ-CP.",
          "line": 13,
          "path": "Chương I. QUY ĐỊNH CHUNG > Điều 2. Hiệu lực thi hành"
        }
      ]
    }
  ],
  "references": [
    {
      "kind": "document",
      "type": "Nghị định",
      "number": "51/2010/NĐ-CP",
      "count": 1,
      "first_text": "Nghị định số 51/2010/NĐ-CP"
    }
  ],
  "article_references": [
    {
      "target": "khoản 3 Điều 5",
      "document": "Nghị định số 51/2010/NĐ-CP",
      "external": true,
      "count": 1
    }
  ],
  "amendments": [
    {
      "path": "Chương I. QUY ĐỊNH CHUNG > Điều 2. Hiệu lực thi hành",
      "action": "bãi bỏ",
      "text": "Nghị định này có hiệu lực thi hành từ ngày 01 tháng 7 năm 2022 và bãi bỏ khoản 3 Điều 5 Nghị định số 51/2010/NĐ-CP."
    }
  ],
  "chunks": [
    {
      "id": "dieu-1",
      "article": "1",
      "path": "Nghị định 123/2020/NĐ-CP > Chương I. QUY ĐỊNH CHUNG > Điều 1. Phạm vi điều chỉnh",
      "heading": "Điều 1. Phạm vi điều chỉnh",
      "text": "Nghị định 123/2020/NĐ-CP > Chương I. QUY ĐỊNH CHUNG > Điều 1. Phạm vi điều chỉnh\n1. Nghị định này quy định việc quản lý, sử dụng hóa đơn khi bán hàng hóa, cung cấp dịch vụ.\n2. Hóa đơn gồm:\na) Hóa đơn điện tử;\nb) Hóa đơn do cơ quan thuế đặt in.",
      "chars": 243,
      "approx_tokens": 81
    },
    {
      "id": "dieu-2",
      "article": "2",
      "path": "Nghị định 123/2020/NĐ-CP > Chương I. QUY ĐỊNH CHUNG > Điều 2. Hiệu lực thi hành",
      "heading": "Điều 2. Hiệu lực thi hành",
      "text": "Nghị định 123/2020/NĐ-CP > Chương I. QUY ĐỊNH CHUNG > Điều 2. Hiệu lực thi hành\nNghị định này có hiệu lực thi hành từ ngày 01 tháng 7 năm 2022 và bãi bỏ khoản 3 Điều 5 Nghị định số 51/2010/NĐ-CP.",
      "chars": 195,
      "approx_tokens": 65
    }
  ],
  "notes": [
    "Text is normalised to Unicode NFC. Lines inside quotation marks (amending text) are not parsed as structure."
  ]
}

Use cases

  • Chunk laws and decrees for a legal chatbot (RAG) without breaking articles
  • Build a table of contents and article index for a document system
  • Extract cited documents and amendment instructions from a decree
  • Convert a .docx regulation into structured JSON

FAQ

Why chunk by article instead of by characters?

An article is the unit lawyers cite and that answers a question; cutting at a fixed size breaks clauses apart. Long articles are split by clause, and each chunk keeps its breadcrumb.

Does it handle amending laws?

Yes: quoted replacement text is not parsed as new articles, and the sentences that amend, supplement, repeal or replace provisions are listed in amendments.

How are tokens counted?

approx_tokens is characters / 3, a fair estimate for Vietnamese with common tokenizers; use the llm-tokens API for exact counts with a given model.

Related APIs

Start with 1,000 free requests every month. Get free API key →