How to get HTML from clipboard?

You can do it with Python!

From How can I edit the source of HTML in the clipboard? ...

#!/usr/bin/env python
import gtk
print (gtk.Clipboard().wait_for_contents('text/html')).data

(just save that in a file called, say, clip.py, then execute python clip.py in the Terminal application)

See also: https://stackoverflow.com/questions/2346924/dump-x-clipboard-data-with-gtk-or-pygtk


  • If it is an email you received which you would like to see its HTML source:

    • View → Message Source
    • Press Ctrl+U
  • If it is an email you are currently writing which you would like to see its HTML source:

    • Edit → Select All, then click the Insert → HTML menu option on your message window.

More info


Yaron's answer is totally correct. There is another option, too:

  1. Once you have selected the message, either

    • go to File > Save as > File, or
    • press Ctrl+S.
  2. Then in the drop down at the bottom right, select "HTML files" and change the file name to match.

  3. Then select a location to save the message locally and, voilà, you have the HTML stored locally.


The answers that are already there stand for what your question appeared to be, and that will still work for Firefox, but in view of your edit, I'll give you what I know.

To my knowledge there is no tool in Ubuntu that will allow you to take copied formatted text and convert to plain HTML. However, there are online tools like this one from wordtohtml.net that will allow you to do this.

Essentially, you'll have to copy your text, then paste it to the left text input box, then you can copy out the html rendering of it from the box on the right.

Hope it helps!


xclip -selection clipboard -t text/html -o # Source of HTML on clipboard

You can change it and send it back also with pipes and xclip or xsel.