PHPackages                             lucadevelop/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. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. lucadevelop/telegram-entities-decoder

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

lucadevelop/telegram-entities-decoder
=====================================

Telegram entities decoder in PHP

v1.4(5mo ago)3431.2k—8.1%52MITPHPPHP &gt;=7.0.0CI passing

Since Jan 20Pushed 5mo ago3 watchersCompare

[ Source](https://github.com/LucaDevelop/telegram-entities-decoder)[ Packagist](https://packagist.org/packages/lucadevelop/telegram-entities-decoder)[ RSS](/packages/lucadevelop-telegram-entities-decoder/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (5)DependenciesVersions (6)Used By (2)

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

Consider to ⭐️ Star this project

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.*

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)

Contacts
--------

[](#contacts)

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

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance70

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community17

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98% 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 ~375 days

Total

5

Last Release

169d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/31da6fa9a280eff91d7a8cc874ec6e0f0b56f5e149f2ea9bfb31a25c7df774eb?d=identicon)[LucaDevelop](/maintainers/LucaDevelop)

---

Top Contributors

[![LucaDevelop](https://avatars.githubusercontent.com/u/68305127?v=4)](https://github.com/LucaDevelop "LucaDevelop (50 commits)")[![Gruven](https://avatars.githubusercontent.com/u/410058?v=4)](https://github.com/Gruven "Gruven (1 commits)")

---

Tags

entitieshtmlmarkdownphpphp7telegramtelegram-bottelegram-bot-api

### Embed Badge

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

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

###  Alternatives

[mwgg/airports

A JSON collection of ~29k entries with basic information about nearly every airport and landing strip in the world

7683.4k](/packages/mwgg-airports)[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9845.4k](/packages/sauladam-shipment-tracker)[jstewmc/rtf

Read and write Rich Text Format (RTF) documents with PHP

46164.0k6](/packages/jstewmc-rtf)[glauberportella/cnab-layouts-parser

Parser de arquivos de configuração CNAB gerados no projeto https://github.com/glauberportella/cnab-layouts

2154.5k](/packages/glauberportella-cnab-layouts-parser)[tcds-io/php-jackson

A lightweight, flexible object serializer for PHP, inspired by FasterXML/jackson

113.4k10](/packages/tcds-io-php-jackson)

PHPackages © 2026

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