HTML list generator — nested ul and ol lists from indented lines

Type one item per line, indent with two spaces to nest, and get a correctly nested bulleted or numbered HTML list, with the numbering style and start number you choose.

Live demo · real result from this tool
List type

Press Generate to create a result.

Processed on your device — nothing is uploaded.

How to use the HTML list generator

  1. Type your items in Items (one per line; indent 2 spaces to nest). Empty lines are ignored.
  2. Choose the List type: Bulleted <ul> or Numbered <ol>.
  3. For a numbered list, pick the Numbering (1, 2, 3 / a, b, c / A, B, C / i, ii, iii / I, II, III) and the Start at number.
  4. Add a Class (optional) if your CSS styles lists by class.
  5. Copy the HTML and check the Preview.

What it does and when to use it

Lists are easy to write and easy to nest wrongly. A sub-list must sit inside the li of the item it belongs to, and every li and list must be closed in the right order. In a three-level outline it only takes one missing </li> to shift the rest of the page.

Use the generator for tables of contents, feature lists, outlines, recipe steps with sub-steps and documentation menus. Lists of name and description pairs, such as a glossary, fit a definition list better. When the content already exists as HTML and you only need the words, HTML to Text turns lists back into bullets.

How it works

Each line’s indentation is measured: every two spaces (or one tab) is one level. When a line goes one level deeper, a new list opens inside the current li. When it comes back out, the open lists and items are closed. The output is indented two spaces per level so the structure is easy to read. Item text is HTML-escaped, so & becomes &amp;.

On a numbered list, type is added only when it is not 1, and start only when it is not 1. This keeps the code clean.

Worked examples

Recipe steps with sub-steps, numbered with capital letters:

<ol type="A">
  <li>Preheat the oven</li>
  <li>Mix the batter
    <ol>
      <li>Flour</li>
      <li>Eggs</li>
    </ol>
  </li>
  <li>Bake</li>
</ol>

The sub-steps use 1, 2 because type is set on the outer list only.

Continuing a numbered list. Items “Chapter 5” and “Chapter 6” with Start at 5 and class toc give <ol class="toc" start="5">, so the first item is shown as 5.

Nothing to list. A box with only spaces returns “Add at least one item.”

Limits and tips

  • type on an ol sets the numbering, but CSS list-style-type overrides it. If your theme sets list styles, the attribute may not show.
  • Use start for a list that continues after other content, for example after a paragraph between steps 4 and 5. Use the reversed attribute (added by hand) for countdowns.
  • To format a long list you have edited by hand, paste it into the HTML Formatter.

Frequently asked questions

Where does a nested list go in the HTML?
Inside the li of its parent item, after the parent's text. A ul placed directly inside another ul, between two li elements, is invalid HTML, although browsers display it. The generator always puts the sub-list in the right place and closes the parent li after it.
Should I use ul or ol?
Use ol when the order matters, such as steps, rankings or chapters. Use ul when it does not, such as features or ingredients. Screen readers announce both as a list with the number of items, so the choice is about meaning, not looks.
How do I indent with tabs?
A tab counts as two spaces, so one tab or two spaces both make an item one level deeper. If you skip a level, for example by indenting four spaces under a top-level item, the item is placed only one level deeper.
Does the numbering type apply to sub-lists?
No. The type and start attributes go on the outer list only. Nested ol lists start at 1 with normal numbers. To number them differently, add a type to them after copying, or use CSS list-style-type.
Can I put links or bold text in an item?
The text is escaped, so typing HTML shows the tags as text. Generate the list first, then add links in your editor. For a list of links used as site navigation, the HTML Nav Menu Generator writes them for you.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close