1001Ferramentas
Utilities

HTML Rating Stars Builder

Builds a sequence of filled/empty stars representing a numeric rating from 0 to 5.



  

Star ratings made of plain characters

You have a 4.5 rating to show on a product card, inside an email template, or in a small internal dashboard, and pulling an entire icon library for five symbols feels like overkill. Unicode already ships the star characters. The tedious part is working out how many render full, how many stay empty, and what to do with the half step in the middle.

Two fields drive it: the rating and the maximum. The integer part becomes filled stars, a fractional part of 0.5 or more becomes one half star, and whatever is left up to the maximum becomes empty stars. The output comes wrapped in a span carrying a title attribute in rating/max form, so hovering reveals the exact number. Nothing here is an image or an SVG, just text you can paste anywhere.

Three things worth checking. Use a dot as the decimal separator, since a comma makes the parse fall back to zero and the whole row renders empty. The rating is never clamped to the maximum, so 8 out of 5 happily returns eight filled stars. The half-star glyph is U+2BE8, a half black circle that plenty of font stacks do not carry, so preview it where it will actually ship. There is no copy button either, so select the block and hit Ctrl+C. Everything runs locally in your browser.

Frequently asked questions

Can I type the rating with a comma?
No. The parser is JavaScript Number(), which rejects 4,5 and returns zero. Write 4.5 instead.
Will this put star ratings in Google search results?
No. Search stars come from schema.org structured data such as AggregateRating or Review, not from Unicode characters in the page body. These symbols are purely visual.
Is it accessible to screen readers?
Only partly. A screen reader reads each star character in turn, which gets noisy. Add an aria-label with the numeric rating and mark the stars themselves as decorative.

Related Tools