PHPackages                             ivnkara/telegram-entities-decoder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ivnkara/telegram-entities-decoder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ivnkara/telegram-entities-decoder
=================================

Telegram entities decoder in PHP

v0.0.3(2y ago)047MITPHPPHP &gt;=7.0.0

Since Oct 31Pushed 2y agoCompare

[ Source](https://github.com/Ivnkara/telegram-entities-decoder)[ Packagist](https://packagist.org/packages/ivnkara/telegram-entities-decoder)[ RSS](/packages/ivnkara-telegram-entities-decoder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (4)Used By (0)

telegram-entities-decoder
=========================

[](#telegram-entities-decoder)

[![Build Status](https://camo.githubusercontent.com/8f68ecec4bbb51a10d5df8d12a901e5ad070a00284e43cd249c5cc2685aacbab/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c756361446576656c6f702f74656c656772616d2d656e7469746965732d6465636f6465722f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/LucaDevelop/telegram-entities-decoder/build-status/master) [![Latest Stable Version](https://camo.githubusercontent.com/508be35747f536579fffba46e3975b9839d75fe28af5e7acf05a1fe2a687bdfa/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6c756361646576656c6f702f74656c656772616d2d656e7469746965732d6465636f6465723f646973706c61795f6e616d653d746167266c6162656c3d737461626c65)](https://packagist.org/packages/lucadevelop/telegram-entities-decoder) [![Total Downloads](https://camo.githubusercontent.com/fb5187ff1e8d64b22c3991d635e4117f7761f478a19462aba65025f6fbe7f479/687474703a2f2f706f7365722e707567782e6f72672f6c756361646576656c6f702f74656c656772616d2d656e7469746965732d6465636f6465722f646f776e6c6f616473)](https://packagist.org/packages/lucadevelop/telegram-entities-decoder) [![Latest Unstable Version](https://camo.githubusercontent.com/2bc09be1d1540178fcfb87ad46aefa2eb9db1e94a85f5340ba97c4e1524c7c23/687474703a2f2f706f7365722e707567782e6f72672f6c756361646576656c6f702f74656c656772616d2d656e7469746965732d6465636f6465722f762f756e737461626c65)](https://packagist.org/packages/lucadevelop/telegram-entities-decoder) [![License](https://camo.githubusercontent.com/f3b3f825343b5c7d6dd2b9c5d1b045c7b0900caff4fc94521ba538ce27a3b2af/687474703a2f2f706f7365722e707567782e6f72672f6c756361646576656c6f702f74656c656772616d2d656e7469746965732d6465636f6465722f6c6963656e7365)](https://packagist.org/packages/lucadevelop/telegram-entities-decoder) [![PHP Version Require](https://camo.githubusercontent.com/13ec85798a66b9fcff98d2e1a7bee9711256ed3030248ce1733ae535a78719bb/687474703a2f2f706f7365722e707567782e6f72672f6c756361646576656c6f702f74656c656772616d2d656e7469746965732d6465636f6465722f726571756972652f706870)](https://packagist.org/packages/lucadevelop/telegram-entities-decoder)

[![EntityDecoder](https://user-images.githubusercontent.com/68305127/164949030-622a200e-8c18-4480-b8e2-08476801bb90.PNG)](https://user-images.githubusercontent.com/68305127/164949030-622a200e-8c18-4480-b8e2-08476801bb90.PNG)

This class decode style entities from Telegram bot messages (bold, italic, etc.) in text with inline entities that duplicate (when possible) the exact style the message had originally when was sended to the bot. All this work is necessary because Telegram returns offset and length of the entities in UTF-16 code units that they've been hard to decode correctly in PHP

Compatibility
-------------

[](#compatibility)

PHP &gt;= 7.0

Features
--------

[](#features)

- Decode entities from text messages and attachments caption.
- Supports all Telegram parse modes (Markdown, HTML and MarkdownV2). HTML has more entropy but it's easily the best and it's recommended.
- Supports emoji in the text field
- Easy to use

*NOTE: Markdown parse mode is deprecated and no longer up-to-date so it doesn't support all entities. Use MarkdownV2 or HTML.*

TODOs
-----

[](#todos)

1. Manage Exceptions and wrong inputs
2. Find an easier way to calculate emoji length that not use a regexp or any other way that require to be updated from emoji DB.
3. Right to left writing compatibility

Example usage
-------------

[](#example-usage)

```
$entity_decoder = new EntityDecoder('HTML');
$decoded_text = $entity_decoder->decode($message);

```

*See demo folder for full example*

Composer
--------

[](#composer)

```
composer require lucadevelop/telegram-entities-decoder

```

Usage:

```
require 'vendor/autoload.php';
use lucadevelop\TelegramEntitiesDecoder\EntityDecoder;
[...]
$entity_decoder = new EntityDecoder('HTML');
$decoded_text = $entity_decoder->decode($message);

```

Credits
-------

[](#credits)

- Telegram docs:
- Inspired By: [php-telegram-bot/core#544 (comment)](https://github.com/php-telegram-bot/core/issues/544#issuecomment-564950430)
- Emoji detection (with some customizations) from:

Contacts
--------

[](#contacts)

[![Telegram](https://camo.githubusercontent.com/1e954485ffe8d04a91bb7dc07f5dbdb90a054ca8d9cd358d0ddbbc750f9226c7/68747470733a2f2f74656c656772616d2e6f72672f66617669636f6e2e69636f)](https://camo.githubusercontent.com/1e954485ffe8d04a91bb7dc07f5dbdb90a054ca8d9cd358d0ddbbc750f9226c7/68747470733a2f2f74656c656772616d2e6f72672f66617669636f6e2e69636f) [@LucaDevelop](https://t.me/LucaDevelop)

###  Health Score

17

—

LowBetter than 6% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity8

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity29

Early-stage or recently created project

 Bus Factor1

Top contributor holds 90.9% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~4 days

Total

3

Last Release

914d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7f64e46b2629aeb65140152bd0f3366066f0b78b0a1ecc517e5716cecf9089eb?d=identicon)[Ivnkara](/maintainers/Ivnkara)

---

Top Contributors

[![LucaDevelop](https://avatars.githubusercontent.com/u/68305127?v=4)](https://github.com/LucaDevelop "LucaDevelop (40 commits)")[![tuduk](https://avatars.githubusercontent.com/u/44131676?v=4)](https://github.com/tuduk "tuduk (4 commits)")

### Embed Badge

![Health badge](/badges/ivnkara-telegram-entities-decoder/health.svg)

```
[![Health](https://phpackages.com/badges/ivnkara-telegram-entities-decoder/health.svg)](https://phpackages.com/packages/ivnkara-telegram-entities-decoder)
```

###  Alternatives

[alexandresalome/assetic-extra-bundle

Extra feature for Assetic (asset directory)

1811.4k](/packages/alexandresalome-assetic-extra-bundle)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
