Fill a Word Template (.docx) with JSON Data Online
Fill a Word .docx template with {placeholders}, table-row loops and conditions from JSON; merge many rows into a zip of documents. Formats VND and dates.
Result
Press “Run” to see the result.
Upload a Word document containing tags and send the data as JSON: {ho_ten} inserts a value (dotted paths such as {ben_a.ten} work), {#items}…{/items} repeats content for each element of an array, {#co_bao_hiem}…{/co_bao_hiem} shows a block only when the value is true and {^co_bao_hiem}…{/co_bao_hiem} when it is false or empty. A loop whose tags sit in a table row repeats the row (invoice and contract lines), one across paragraphs repeats the paragraphs, one inside a paragraph repeats the text in place. {$index} numbers the rows.
Filters format values the Vietnamese way: {luong|money} gives 15.500.000, {luong|words} "Mười lăm triệu năm trăm nghìn đồng", {ngay|date} 11/11/2026, {ngay|date_vi} "ngày 11 tháng 11 năm 2026", plus upper, lower, trim and default:…. Tags that Word split into several runs while you typed (spell check, formatting changes) are merged first, so they work as typed; formatting of the first character of the tag is kept. Headers, footers and footnotes are filled too; {{name}} delimiters are detected automatically.
Send rows (an array) instead of data to merge many documents at once: you get a zip, file names from filename such as HD_{so_hd}. action=tags lists the tags of a template. The output is .docx (no PDF conversion); files are processed in memory and not stored.
Use this in your code
curl -X POST "https://apibox.io.vn/v1/docx-template" \
-H "Authorization: Bearer YOUR_API_KEY" \
-F "0=@./my-file"const form = new FormData();
form.append('0', fileInput.files[0]);
const res = await fetch('https://apibox.io.vn/v1/docx-template', {
method: 'POST',
headers: { Authorization: 'Bearer YOUR_API_KEY' },
body: form,
});
console.log(await res.json());import requests
res = requests.post(
"https://apibox.io.vn/v1/docx-template",
headers={"Authorization": "Bearer YOUR_API_KEY"},
files={"0": open("my-file", "rb")},
timeout=30,
)
print(res.json())<?php
$ch = curl_init('https://apibox.io.vn/v1/docx-template');
curl_setopt_array($ch, [
CURLOPT_RETURNTRANSFER => true,
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_HTTPHEADER => ['Authorization: Bearer YOUR_API_KEY'],
CURLOPT_POSTFIELDS => ['0' => new CURLFile('my-file')],
]);
$response = curl_exec($ch);
print_r(json_decode($response, true));API documentation → Get a free API key
FAQ
My tag is not replaced: why?
Check action=tags: the tag must use straight braces {…} and no line break inside. Split runs are handled automatically; a missing value is reported in missing_fields (or the x-missing-fields header).
How do I repeat a table row?
Put {#items} in the first cell and {/items} in the last cell of the row (or of a later row): the row(s) are copied for each item, with {$index} as the line number.
Can it output PDF?
No, the result is a .docx. Convert it with Word / LibreOffice, or use /v1/md-pdf for documents written in Markdown.