# Sablon

> Ruby document template processor based on docx templates and Mail Merge fields

Source: https://talira.ai/catalog/sablon-5bjabghv
Every listing: https://talira.ai/catalog.md

- Kind: Open source
- Types: Library, Command-line tool
- Categories: [documents / generation / word templates](https://talira.ai/categories/documents/generation/word-templates), [languages / ruby](https://talira.ai/categories/languages/ruby)
- Licence: MIT[^2][^3]
- Pricing: Free and open source[^2]
- Pricing notes: MIT-licensed and free.
- Free tier: yes[^2]
- Self-hostable: yes[^1]
- Creator: Yves Senn

Sablon is a Ruby gem that fills Word (.docx) templates: the template is an ordinary Word document with MailMerge fields such as `«=title»`, and Sablon replaces them with values from a Ruby hash or objects. Fields also drive conditionals (if, elsif, else), loops that repeat table rows or list items, nesting and comments, and you can insert raw WordprocessingML, HTML (converted to Word paragraphs, tables and lists) or images. It ships a `sablon` executable that renders a template from JSON. Yves Senn started it in 2014; it's MIT-licensed and still released (0.4.4 in November 2026).

## Links

- GitHub: https://github.com/senny/sablon

## Problems it solves

- fill a Word template from my Rails app and keep all the styling the business team set up in Word
- repeat a row of a Word table for every invoice line in a Ruby report
- show or hide a section of a .docx depending on a value, generated from Ruby
- turn HTML from our rich text field into real Word paragraphs and tables inside a generated document
- put a different photo into each generated Word document from a Ruby script
- templates made with Word's own mail merge fields instead of curly-brace tags people mistype
- render a .docx from a JSON file on the command line without writing a program
- an MIT-licensed Ruby gem for Word document generation with no paid modules

## Features

- MailMerge-field templates (`«=field»`) made in Word
- method calls and nested hash lookups (`«=buyer.address.street»`)
- conditionals with predicates, elsif and else
- loops that repeat table rows or list items, with nesting
- insert raw WordprocessingML, inline or as paragraphs
- HTML insertion converted to Word paragraphs, tables and lists, with configurable tag and CSS conversion
- images from files, URLs or IO objects, sized by the placeholder or explicitly (beta)
- template comments that don't appear in the output
- `sablon` executable that renders a template from JSON

## Limitations

- Doesn't convert every CSS style when inserting HTML: only a small subset of inline styles has a Word equivalent[^1]

## Capabilities

- Has a command line tool: plan not known

## Trust

Overall: 0.28 out of 1.
Signals: backing 0.20, extensibility 0.20.

- created by Yves Senn

Warnings:

- GitHub activity not fetched yet

## Alternatives

- [docxtpl](https://talira.ai/catalog/docxtpl-yhjaa0ty.md): Use a docx as a jinja2 template
- [Docmosis](https://talira.ai/catalog/docmosis-xet3917k.md): API-first, template-based document generation
- [docxtemplater](https://talira.ai/catalog/docxtemplater-gjcbyhm2.md): Powerful Word, PowerPoint and Excel generation
- [Carbone](https://talira.ai/catalog/carbone-hz5gt655.md): Generates PDF, DOCX and other documents from JSON data and Office templates
- [docx-templates](https://talira.ai/catalog/docx-templates-w28fxj7t.md): Template-based docx report creation for both Node and the browser
- [easy-template-x](https://talira.ai/catalog/easy-template-x-cyxb4adx.md): Generate docx documents from templates, in Node or in the browser

## Sources

[^1]: https://github.com/senny/sablon/blob/master/README.md (checked 20 Nov 2026)
[^2]: https://github.com/senny/sablon/blob/master/LICENSE.txt (checked 20 Nov 2026)
[^3]: https://rubygems.org/gems/sablon (checked 20 Nov 2026)
