Socialx.com

Can you embed X (Twitter) in an iframe?

Yes, but only with the official embed code, not with an iframe of the post page. X documents the Embed post code with widgets.js.

Checked Test again

Live check

What the main page sends

Result of
Post pagePartial
x.com/Interior/status/463440424141459456
X-Frame-Options
SAMEORIGIN (ignored)
CSP frame-ancestors
'self' https://x.com https://x.com:443 https://twitter.com https://twitter.com:443
Response
200 OK · 140 ms · HTTPS
Embed codeNot checked
x.com/{username}/status/{post-id}

Not checked: needs your own link. X (Twitter) has no public sample we can load.

Test your link

Steps

How to embed X (Twitter)

  1. Open the post on x.com.
  2. Open the post menu. Then clickEmbed Post
  3. On publish.x.com, set the look of the embedded post.
  4. For a reply, select Hide Conversation to hide the parent post.
  5. Click Copy Code. Then paste the code into the HTML of your page.

Embed code

Paste this into your page

HTML
<blockquote class="twitter-tweet">
  <a href="https://x.com/{username}/status/{post-id}">{post text}</a>
</blockquote>
<script async src="https://platform.x.com/widgets.js" charset="utf-8"></script>

The widgets.js script changes the blockquote into the full post. Without the script, only the plain text shows.

URL patterns

Swap the link you have for the embed URL

  • You havehttps://x.com/{username}/status/{post-id}Use in the iframehttps://publish.x.com/oembed?url=https://x.com/{username}/status/{post-id}

The oEmbed URL gives the embed code for a post URL. Use it in a CMS or an app.

Good to know

  • Posts from protected accounts have no embed code.
  • Set data-conversation="none" to hide the parent post of a reply.
  • Set data-theme="dark" for light text on a dark background.
  • Set data-cards="hidden" to hide photos, videos and link cards.
  • Set data-width to a value from 250 to 550 pixels.
  • Set data-dnt="true" to stop X from using the post and your page for personalized ads and suggestions.

Sources

Profile updated

Know before you embed.

Free, no sign-up, nothing stored. Paste a URL and get a verdict, a live preview, and the fix.