Skip to content
Truncate HTML code to limit its length by number of words without losing markup.
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.


Cutter.js is a library used for truncating HTML code to limit its length, by word number, without losing the markup.


Cutter solves the problem when its needed to cut some content by a number of words but its mandatory no lose any markup. Cutter cuts the content to the number of requested words and if needed puts a link to open the full content again.

Some benefits:

  • No markup is lost.
  • Framework agnostic.
  • The content can be written without take care about the full content.
  • Not needed to have two different contents.
  • Crossbrowsing
    • Tested on:
      • IE >= 6
      • Firefox >= 3
      • Safari >= 4
      • Google Chrome >= 4
      • Opera >= 9.5
  • Only 1.5kb when Gzipped.

(Links will only work if you clone the repo.)

API documentation

Examples to see for yourself!


Before using it:

Insert in your code:

<script type="text/javascript" src="/path/to/your/js/libs/Cutter.js"></script>

Simple execution:, oTarget, nWords, [configuration]);


oAplyTo: The element that will have its text truncated

oTarget: The element where the truncated content will be placed.

nWords: Maximum word count. Any additional word will be truncated.


configuration: This object contains both the text that will be displayed in the "view more" link and its style.

configuration.viewMoreText: The text that will be displayed in the "view more" link. The default is "View more"

configuration.class: The class that will be applied to the "View more" link. The default is "more"

Tip: oTarget Could be the same oApplyTo element if we want to replace the full content with the cut content


cutElement = document.getElementById("test");, cutElement, 30, {viewMoreText:"Expand", class:"expandLink"});

*On the example above, the element with id "test" will display a maximum of 30 words and a link entitled "Expand". The "expandLink" class will be applied to this link. The remaining words that were previously truncated will show up in the element when the link is clicked.


Cutter.js is licensed under the MIT license.

You can’t perform that action at this time.