Step 1: Open up console by pressing F12 on ChatGPT conversation
Step 2: Paste the code below and click enter
(() => {
// Select all messages (inspect the page to confirm the correct selector)
const messages = document.querySelectorAll('[data-message-author-role]');
let htmlOutput = '';
messages.forEach(msg => {
const role = msg.getAttribute('data-message-author-role') || 'ChatGPT';
const contentEl = msg.querySelector('.markdown'); // ChatGPT messages have .markdown for HTML content
if (!contentEl) return; // skip empty messages
// Wrap each message in a div with role label
htmlOutput += ``;
htmlOutput += `${role === 'user' ? 'User' : 'ChatGPT'}:
`;
htmlOutput += contentEl.innerHTML; // grab the raw HTML
htmlOutput += `\n`;
});
// Copy HTML to clipboard using Chrome console helper
copy(htmlOutput);
console.log('✅ HTML copied to clipboard!');
})();
Step 3: The html should be copied to clipboard. Paste below