30

I want to copy the title of a web page (or what appears within the tab, the part always visible) and paste that text somewhere.

How can I do this in Chrome?

14 Answers 14

35

Use a bookmarklet:

javascript:window.prompt("Copy to clipboard: Ctrl+C, Enter",document.title);

Credit for this window.prompt trick goes to Jarek Milewski. This bookmarklet also works in ANY browser, even Netscape 3, and not just Chrome.

7
  • that's a great idea. Sep 7, 2011 at 6:00
  • I'm not sure what i'm supposed to do... Your talking about "bookmarklets"?
    – wizlog
    Sep 25, 2011 at 17:45
  • @wizlog: Yes bookmarklets. The above link gives step-by-step instructions. Try dragging [Copy Webpage Title](javascript:window.prompt("Copy to clipboard: Ctrl+C, Enter",document.title);) to your bookmarks bar.
    – William C
    Sep 26, 2011 at 21:05
  • 1
    Better version of this answer here
    – Yarin
    Oct 29, 2015 at 16:44
  • 1
    Cool, I just selected the code and dragged text on Firefox's bookmarks bar. A charm!
    – SΛLVΘ
    Nov 7, 2015 at 15:06
21

Add a bookmark by hitting CtrlD or clicking on the star on the right end of the address bar.

Copy title.

Click on "Remove".

3
  • 2
    Over the address bar or on the right hand side of the address bar?
    – wizlog
    Dec 2, 2015 at 22:47
  • 1
    Clever hack! This answer is great because it gives the title instantly without reloading the page or searching through source code.
    – wisbucky
    May 22, 2019 at 21:08
  • 1
    You can also do this with keyboard only: ctrl+D (bookmark), ctrl+C (copy), tab tab tab space (remove).
    – wisbucky
    May 22, 2019 at 21:18
9

This can be achieved through the page source code:

  1. Right click on the page and select 'View Source'
  2. Look for the <title> tag
  3. Select and copy the text.

view source on a page in Chrome

4
  • 1
    Assuming I understood your question correctly... Sep 7, 2011 at 3:35
  • You did... is there a shortcut though?
    – wizlog
    Sep 7, 2011 at 3:36
  • View Source keyboard shortcut is: CTRL+U Sep 7, 2011 at 3:44
  • 1
    Note: this will require to load the web page again, so if it's a complex web page on a slow server, you may have to wait a long time for the source to load. Also, on complex pages, you may have to search past pages of <meta> and scripts to find <title>. This answer is much faster: superuser.com/questions/332717/…
    – wisbucky
    May 22, 2019 at 21:15
9

The above script has the annoying habit of creating a blank page with the title at the top, in plain text, making you have to go back to the page whose title you wanted to copy. At least in Firefox 24.0.

A far more effective script that keeps you on the page is:

javascript:var%20title=document.title;if(title){var%20re=/(\\|\/|:|\*|\?|\%22|<|>|\|)/gi;title=title.replace(re,'');void(prompt('Page%20Title',%20title));}
3
  • Here is the version that also adds the original url after line break: javascript:var title=document.title;if(title){var re=/(\\|\/|:|\*|\?|\"|<|>|\|)/gi;title=title.replace(re,'') + "\r\n" + document.location;void(prompt('Page Title', title));}
    – Eugene
    Sep 13, 2017 at 13:52
  • ... or just click Cancel on the dialog from above script instead of Ok, and it won't create such an extra page (tested on Chrome)
    – PHPirate
    Oct 2, 2019 at 13:34
  • Thanks for sharing! It looks like this script removes "|" and ":" from the page titles. Jan 21, 2020 at 13:49
2

You can use the Google Chrome extension Copy URL + Title:

Features:

  • Copy Page URL
  • Copy Page Title
  • Copy Page HTML Link
  • Copy Page Title and URL
  • Copy URL of all Tab
  • Copy Title of all Tab
  • Copy HTML Link of all Tab
  • Copy Title and URL of all Tab

Also available for Opera from https://addons.opera.com/en/extensions/details/copy-url-title/

enter image description here

1
  • I wonder if there is any such extension out there that does not record browsing history.
    – user345394
    Dec 19, 2020 at 19:01
2

This bookmarklet copies the page Title to the clipboard with a single click.

javascript:copyToClipboard = str => {
const el = document.createElement('textarea'); 
el.value = str; 
el.setAttribute('readonly', ''); 
el.style.position = 'absolute'; 
el.style.left = '-9999px'; 
document.body.appendChild(el); 
const selected = document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false; 
el.select(); 
document.execCommand('copy'); 
document.body.removeChild(el); 
if (selected) {
document.getSelection().removeAllRanges(); 
document.getSelection().addRange(selected); 
} 
};
copyToClipboard(document.title);
1

An answer inspired by SΛLVΘ's answer, although not identical:

Bookmark that page.

In the list of bookmarks, right click on that bookmark, choose Edit, and you will see the name and the url; by default, the name is the tab's title, unless you modify it

1

If you need Markdown as the end result, use Chromium Extension Copy Tab Info.

SCREENSHOT

Features

Active tab in current window

  • Copy title of active tab in current window as string
  • Copy URL of active tab in current window as string
  • Copy link of active tab in current window as HTML
  • Copy link of active tab in current window as Markdown
  • Copy link of active tab in current window as Markdown ordered list item
  • Copy link of active tab in current window as Markdown unordered list item

All tabs in current window

  • Copy titles of all tabs in current window as text
  • Copy URLs of all tabs in current window as text
  • Copy links of all tabs in current window as HTML ordered list
  • Copy links of all tabs in current window as HTML unordered list
  • Copy links of all tabs in current window as Markdown ordered list
  • Copy links of all tabs in current window as Markdown unordered list

All tabs in all windows

  • Copy titles of all tabs in all windows as text
  • Copy URLs of all tabs in all windows as text
  • Copy links of all tabs in all windows as HTML ordered list
  • Copy links of all tabs in all windows as HTML unordered list
  • Copy links of all tabs in all windows as Markdown ordered list
  • Copy links of all tabs in all windows as Markdown unordered list
1
  • It's great, thanks! But what if I only want use Copy link of active tab in current window as Markdown? Could you add a default setting, if it set, the press of Copy Tab info icon not show dropdown, but do what the default setting.
    – roachsinai
    Mar 10, 2020 at 12:13
1
  • Use the menu item "More tools" - "Save page as..." (or Ctrl + S).
  • When "Save As" dialog box is displayed:
    • Delete ".html" suffix from the text in "File name" text box
    • Copy the text from "File name" text box (which should be the page title).
    • Cancel "Save As" dialog box

"Save As" dialog box

1

This bookmarklet copies the title to the clipboard:

javascript:navigator.clipboard.writeText(document.title);

Browser compatibility: https://developer.mozilla.org/en-US/docs/Web/API/Clipboard/writeText#browser_compatibility

How to create a bookmarklet

  1. Bookmark any web page (e.g. this page) and save it to the Bookmarks Bar (in Chrome) or Bookmarks Toolbar (in Firefox) or Favoutires (in Safari).
  2. Right click on the new bookmark and choose Edit Bookmark.
  3. Change the Name to something meaningful, e.g. "Copy Title"
  4. In the URL copy and paste the JavaScript: javascript:navigator.clipboard.writeText(document.title);
  5. Click on Save
  6. Now when you click on the bookmarklet it will copy the title into the clipboard.
  7. Paste into the destination document or app
0

Drag page icon to the bookmarks toolbar

One simple way that doesn't require any extras is to drag the small icon to the left of the URL to the Bookmarks bar (use CTR+Shift+B or Command+Shift+B to show/hide it), and then right-click on the new bookmark, pick Edit and copy the title.

enter image description here

Drag page icon to folder or the desktop

You can also drag the icon to a folder or to your desktop. On most systems this will create a bookmark file and set the page title as file name, from where it can be easily copied.

Drag page icon directly into a rich text document window

If you drag the page icon into Pages, Word, LibreOffice, Notes, etc on OSX this will insert a link with the page title as text and the URL as link target. On Windows and Linux just the plain text URL will be inserted, so it is not as handy, but can still be useful.

For example, the page icon from this SO page can be dragged directly into the reply edit form. Selecting the URL in the address bar and dragging it to an editable field usually has the same effect, and this is the alternative on OSX for example when you want the actual URL to be inserted instead of the linked title in a richtext edit.

0

Here's a bookmarklet that copies the title + url in markdown format

javascript:var title=document.title;if(title){var re= /(\\|\/|:|\*|\?|\"|<|>|\|)/gi;title="[" + title.replace(re,%27%27) + "]("+ document.location   + ")";void(prompt(%27Page Title%27, title));}
0

There is an extension for it. Copy URL To Clipboard - Chrome Web Store

2
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Feb 14 at 18:44
  • No, @Community. You are mistaken. The answer is sufficient. Shoo, be gone.
    – Darek
    Feb 16 at 0:27
0

Building on the javascript mentioned by bugz above
( javascript:navigator.clipboard.writeText(document.title); )

... use the following one in order to preserve the URL in the address field:

javascript:navigator.clipboard.writeText(document.title);history.replaceState({},"",location.href);

Source: topic/47747/copy-page-title | Vivaldi Forum

New contributor
user8395964 is a new contributor to this site. Take care in asking for clarification, commenting, and answering. Check out our Code of Conduct.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.