← All posts
Guide

LINE Flex Message Box Nesting: Audit the 20-Level Limit

LINE Messaging API now limits Flex Message box nesting to 20 levels. The specification change took effect on November 19, 2026, according to LINE’s official Japanese announcement. Count the outermost box as level 1, its child box as level 2, and continue down each branch. Audit the final generated message—not just its source template—and simplify any branch exceeding that limit.

Count boxes, not JSON indentation

The limit concerns nested boxes, not the total number of boxes in a message. LINE’s Flex Message elements guide distinguishes containers, blocks, and components: a bubble or carousel is a container, while a box is a component that can contain other boxes.

Do not count every JSON object, array, or indentation level as another box. Equally, do not overlook the outermost box used by a block such as body.

This illustrative component tree has a maximum box depth of 3, not five:

bubble
  body: box                 depth 1
    box                     depth 2
      text
    box                     depth 2
      box                   depth 3
        text

Sibling boxes do not accumulate depth. Inspect the deepest ancestor-to-descendant box chain, and check each block and each bubble in a carousel independently. A large number of shallow siblings and one deeply nested branch are different structural problems.

The practical takeaways are:

  • Start counting at the outermost box, not the Flex Message envelope.
  • Check every generated branch, including optional content.
  • Remove unnecessary nesting without removing meaningful information or actions.
  • Keep depth checks separate from other message validation and visual testing.

If your real problem is choosing a message format rather than repairing an existing Flex layout, start with the buttons-template alternatives comparison.

Audit the generator, not only the saved design

A reusable component may look shallow on its own but acquire more wrapper boxes when composed into a card. The right review artifact is the final Flex JSON after localization, conditional sections, and shared components have been applied.

Recommended audit procedure:

  1. Collect representative outputs. Include each production card family and its optional sections. Use synthetic content instead of exporting customer records into review tools.
  2. Walk each component tree. Carry the current box depth along a branch; increment it only when entering a box. Report the deepest path as well as the maximum depth so an editor can locate the responsible wrapper.
  3. Check generated variants. Include long localized text, missing images, optional notices, and repeated item sections. These are proposed test cases, not observed incidents.
  4. Place the check after composition. A template check alone cannot catch wrappers added by a later rendering step.
  5. Keep other validators. Passing the depth check does not establish that all message fields, actions, or content meet LINE’s requirements.

Treat any local depth checker as a focused lint rule, not a replacement for LINE’s message-object validation reference.

Flatten deliberately, then test the layout again

Start with boxes that exist only because several reusable components each add a wrapper. Before removing one, record the layout responsibility it currently owns. LINE’s layout documentation explains how parent orientation and child sizing interact; changing a parent can change the visual result even when all text remains present.

Candidate changeReview before accepting it
Remove a redundant wrapperConfirm orientation, spacing, sizing, and alignment still express the intended layout
Move related sections to sibling boxesConfirm reading order and grouping remain clear
Split a dense design into separate bubblesReconsider navigation and validate each resulting bubble
Replace decorative nesting with a simpler designRetain important text, action labels, and destinations

Do not automatically delete the deepest node or truncate the JSON. That might remove a customer action or important support information rather than repair the layout.

After restructuring, compare the old and new action destinations. The LINE URI action guide addresses link validation separately; a shallower card does not prove its links are correct.

Use the Flex Message Simulator workflow and controlled client tests. Keep structural acceptance and readability as separate checks. In a local regression suite, a chain of 20 boxes should pass the depth rule and a chain of 21 should fail it; these expected lint outcomes do not certify the rest of either message.

Keep native Flex sending separate from UnifyPort

This change concerns the official LINE Messaging API. UnifyPort’s message support matrix documents normalized sending types but does not document a native LINE Flex Message sending payload. Do not put Flex JSON into an undocumented field and assume it will render.

Use LINE’s official path when native Flex cards are required. UnifyPort’s unofficial interface is a separate option for supported messaging workflows; switching interfaces is not a fix for an over-nested official card.

FAQ

Is the limit 20 boxes per message?

No. It is 20 levels along a nested box chain. Siblings are not added together to calculate depth.

Does the bubble count as the first box?

No. A bubble is a container. The outermost box is level 1, including a box used as the body block.

Does a passing depth check guarantee delivery?

No. It checks one structural constraint. Complete message validation, visual review, sending eligibility, and observed delivery remain separate concerns.

Next step and sources

Audit one fully generated card, locate its deepest box chain, and verify any simplified layout before rollout. If choosing a sending interface, consult the UnifyPort capability matrix first.

Official sources checked on 2026-11-22:

UnifyPort API

Turn messaging integration into a stable product pipeline.

Start by sending through one API, then bring every inbound message back into your business system with standard events.