What is lexMerge?
lexMerge is a high-precision document automation engine purpose-built for the legal industry.
lexMerge merges structured data into dynamic legal templates—usually .docx or .pdf—to generate final documents that reflect jurisdictional requirements, party-specific details, and context-sensitive legal language.
Unlike generic form fillers, lexMerge builds state-specific research into every assembly, ensuring that documents created with our system take into account the intricacies of state law.
What does lexMerge do?
lexMerge takes structured JSON data—typically collected through form submissions or API integrations—and transforms it into final, human-readable legal documents by:
- Selecting the correct template(s) based on custom-defined routing rules.
- Applying advanced merge logic to populate variables, apply formatting, and insert or exclude clauses based on conditional logic.
- Outputting high-quality documents in
.docxor.pdfformat. - Optionally delivering documents to end users by email, based on logic-driven delivery rules.
This allows law firms and legaltech platforms to automate document drafting at scale while retaining full control over legal language, formatting, and compliance.
How does lexMerge work?
lexMerge is built in Laravel and consists of the following functional layers:
1. Template Engine
- Templates are authored by attorneys using Microsoft Word (
.docx) or PDF editors. - They contain embedded Smarty template syntax, which supports:
- Variable insertion (e.g.,
{$client_name}) - Conditional logic (e.g.,
{if $is_married}...{/if}) - Loops and nested structures
- Clause-level toggles and formatting options
- Variable insertion (e.g.,
2. Input Transformation
- Incoming data arrives as structured JSON (usually via webhook from a form).
- Fields may include suffixes like:
_tf: converted to boolean (true/false)_dt: parsed into standard and ordinal date formats_st: expanded into state name, abbreviation, or other variants
- LexPress (a WordPress-based front-end plugin) often performs this preprocessing, but the logic can also be internalized in a standalone deployment.
3. Template Routing Rules
- Users define logic-based routing rules that determine which templates are used based on incoming data.
- Rules are composed of conditional logic (e.g.,
field_a == "X" && field_b != "Y"). - Nested groups of conditions using AND/OR logic are supported.
- Rules are stored as serialized trees and evaluated during each request.
4. Merge Engine
- Once a template is selected, the engine:
- Loads the template file
- Applies Smarty logic using the transformed JSON
- Outputs a fully populated
.docxor.pdffile
- Merges can be batched, queued, or triggered individually.
5. Delivery Rules
- Email delivery can be conditionally triggered post-merge.
- Rules define:
- Whether to send the email
- Who receives it (To, CC, BCC)
- Custom subject and body, both of which support merge tags
- Email delivery is handled via Laravel’s mail system and can be extended to other channels.
6. Admin Interface (Standalone Mode)
Role-based access for team collaboration
When deployed as a standalone app, lexMerge includes:
Template management (upload, edit metadata, delete)
Rule builder UI for template routing and email delivery
Merge history and audit logs
What makes lexMerge different?
Clause-Level Precision: Supports clause selection logic, not just form field merging.
Attorney-Controlled: Attorneys control language, structure, and fallback clauses.
No Raw AI Output: All merge logic uses pre-approved templates, ensuring compliance.
Extensible and Scalable: Integrates with Gravity Forms, Zapier, APIs, and other data sources.
Automation-First: Designed to be embedded in automated workflows, productized legal services, and client-facing platforms.