Answers.Body: <p>No need for a plugin, just use twig's <code>slice</code> filter, combined with the <code>striptags</code> filter.</p>
  
  <p>I've thrown in the <code>default</code> filter for good measure, in case the body is empty for some reason.</p>
  
  <pre><code>{{ entry.body|striptags|slice(0,100)|default('Read more') }}...
  </code></pre>
  
  <p><code>slice</code> will simply output the first 100 characters (starting at <code>0</code> the first character), including spaces into the template. <code>striptags</code> ensures that no html tags will be output.</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2016-07-26T18:08:34.837Z
Answers.LastActivityDate: 2016-07-28T08:49:06.307Z
Answers.LastEditDate: 2016-07-28T08:49:06.307Z
Answers.UserDisplayName: Adam Menczykowski
Answers.Body: <p>For my future self:</p>
  <p>This is my solution now in Craft CMS 3 and 4.</p>
  <pre><code>{{ 'Hello world'|truncate(10) }}
  {# Output: Hello… #}
  </code></pre>
  <p>An ellipsis (…) will be appended to the string if it needs to be truncated, by default. You can customize what gets appended by passing a second argument. (Note that a longer appended string could result in more of the original string getting truncated.)</p>
  <p>More configs available too:
  <a href="https://craftcms.com/docs/4.x/dev/filters.html#truncate" rel="nofollow noreferrer">https://craftcms.com/docs/4.x/dev/filters.html#truncate</a></p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-04-12T16:10:19.140Z
Answers.LastActivityDate: 2023-04-12T16:10:19.140Z
Answers.UserDisplayName: mateostabio
Answers.Body: <p>Looks like you can extend twig with extensions. I have not tried this, but I found this extension which preserves HTML.</p>
  
  <p><a href="https://www.versioneye.com/php/dzango:twig-truncate-extension/1.0.8" rel="nofollow">https://www.versioneye.com/php/dzango:twig-truncate-extension/1.0.8</a></p>
  
  <p>I think you have to create a plugin to use it. A fast way is to follow by example on this one perhaps: <a href="https://github.com/lukeholder/craft-inflect" rel="nofollow">https://github.com/lukeholder/craft-inflect</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-26T10:47:55.923Z
Answers.Text: I use this plugin.https://github.com/ehousestudio/craft_hacksaw
Answers.UserDisplayName: Hs Tung
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-26T11:44:17.657Z
Answers.Text: Looks pretty good!
Answers.UserDisplayName: Ryan
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-26T09:45:39.417Z
Answers.LastActivityDate: 2014-10-26T09:45:39.417Z
Answers.UserDisplayName: Ryan
Answers.Body: <p>I found a plugin to solve this.</p>
  
  <p>Which is use this plugin.
  <a href="https://github.com/ehousestudio/craft_hacksaw" rel="nofollow noreferrer">https://github.com/ehousestudio/craft_hacksaw</a></p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2014-10-26T10:47:09.417Z
Answers.LastActivityDate: 2014-10-26T10:47:09.417Z
Answers.UserDisplayName: Hs Tung
Body: <p>I have a rich text output section I want to limit to specific number of characters or words. So user able preview the blog post and link to the full blog. I try  <code>entry.body|slice(0, 100) ~ '...'</code>. But it slice of my html tag and display html code in front end.</p>
  
Tags: <richtext>
Title: Limit text when output richtext
ThreadText: # Limit text when output richtext
  
  (Asked by: username_0 on 2014-10-26)
  
  I have a rich text output section I want to limit to specific number of characters or words. So user able preview the blog post and link to the full blog. I try `entry.body|slice(0, 100) ~ '...'`. But it slice of my html tag and display html code in front end.
  
  **Tags:** richtext
  
  
  ---
  
  ## 4 answers
  
  ### Answer by username_0 on 2014-10-26. Score: 4 | Accepted answer
  
  I found a plugin to solve this.
  
  Which is use this plugin.
  <https://github.com/ehousestudio/craft_hacksaw>
  
  
  ---
  
  ### Answer by username_1 on 2016-07-26. Score: 18
  
  No need for a plugin, just use twig's `slice` filter, combined with the `striptags` filter.
  
  I've thrown in the `default` filter for good measure, in case the body is empty for some reason.
  
  ```
  {{ entry.body|striptags|slice(0,100)|default('Read more') }}...
  
  ```
  
  `slice` will simply output the first 100 characters (starting at `0` the first character), including spaces into the template. `striptags` ensures that no html tags will be output.
  
  
  ---
  
  ### Answer by username_2 on 2023-04-12. Score: 2
  
  For my future self:
  
  This is my solution now in Craft CMS 3 and 4.
  
  ```
  {{ 'Hello world'|truncate(10) }}
  {# Output: Hello… #}
  
  ```
  
  An ellipsis (…) will be appended to the string if it needs to be truncated, by default. You can customize what gets appended by passing a second argument. (Note that a longer appended string could result in more of the original string getting truncated.)
  
  More configs available too:
  <https://craftcms.com/docs/4.x/dev/filters.html#truncate>
  
  
  ---
  
  ### Answer by username_3 on 2014-10-26. Score: 2
  
  Looks like you can extend twig with extensions. I have not tried this, but I found this extension which preserves HTML.
  
  <https://www.versioneye.com/php/dzango:twig-truncate-extension/1.0.8>
  
  I think you have to create a plugin to use it. A fast way is to follow by example on this one perhaps: <https://github.com/lukeholder/craft-inflect>
  
  > **Comments:**
  > **username_0**: I use this plugin.https://github.com/ehousestudio/craft_hacksaw  
  > **username_3**: Looks pretty good!  
  
  ---
  
  