---
schema_version: "1"
id: 6c3d906ed1da11593664f6491faccea994450cd25fc0a27a7ccc8df0c5f095ea
title: Formatted Text
collection: developer
version: current
locale: en-us
portal_url: https://docs.salesforce.com/developer/current/en-us/lightning-base-components/lightning-design-system/guides/lwc/components/lightning/formattedText/lightning-formatted-text.md
canonical_url: https://developer.salesforce.com/docs/platform/lightning-component-reference/guide/lightning-formatted-text.html
source_site: developer.salesforce.com
content_type: documentation
content_hash: fabdd0828ccb34bbd79825c1035dfc4af90a8f4dd7b3ef7b5a0c07c4e48a7998
products:
  - Lightning Component Reference
---

# Formatted Text

**`lightning-formatted-text`**

Displays text, replaces newlines with line breaks, and linkifies if requested.

**For Use In**

Lightning Experience, Experience Builder Sites, Salesforce Mobile App, Lightning Out (Beta), Standalone Lightning App, Mobile Offline

::::::tabset{tabs='["Example", "Develop", "Specifications"]'}

:::::tab

::component-playground{component="formattedText" model="lwc" namespace="lightning"}


:::::

:::::tab

A `lightning-formatted-text` component shows a read-only representation of
text, and can convert URLs and email addresses to links, or "linkify" them.
It also converts the `\r` and `\n` characters into `<br />` tags.

By default, URLs and email addresses show as plain text.
To show URLs and email addresses in a block of text as links, include
`linkify` on the `lightning-formatted-text` tag.

`linkify` wraps URLs and email addresses in anchor tags with
`target="_blank"`. If you don't specify the URL protocol in the text,
the link's `href` uses `https://` or `http://` to match the host domain's
protocol. For example, the component prefixes `www.example.com` with `https://`
if the host domain's protocol is `https://`. The `href` uses `mailto://`
for email addresses.

This example uses domain names without protocols in the text.

<!-- prettier-ignore-start -->
```html
<template>
    <lightning-formatted-text
        value="I like salesforce.com and trailhead.salesforce.com."
        linkify
    >
    </lightning-formatted-text>
</template>
```
<!-- prettier-ignore-end -->

The example renders like this.

<!-- prettier-ignore-start -->
```html
I like <a target="_blank" href="https://salesforce.com">salesforce.com</a> and
<a target="_blank" href="https://trailhead.salesforce.com"
    >trailhead.salesforce.com</a
>.
```
<!-- prettier-ignore-end -->

## Usage Considerations

`lightning-formatted-text` supports these protocols: `http`, `https`,
`ftp`, and `mailto`.

If you're working with hyperlinks and want to specify the `target` value, use
`lightning-formatted-url` instead. If you're working with email addresses only,
use `lightning-formatted-email`.

For rich text that uses tags beyond anchor tags, use
[`lightning-formatted-rich-text`](/docs/platform/lightning-component-reference/guide/lightning-formatted-rich-text.html) instead.

## See Also

[_Object Reference for the Salesforce Platform_: Field Types](https://developer.salesforce.com/docs/atlas.en-us.object_reference.meta/object_reference/field_types.htm)


:::::

:::::tab
::component-specification{component="formattedText" model="lwc" namespace="lightning"}

:::::

::::::
