can I prevent Chrome from truncating strings in the dev console?
--------------------------------------------------
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Melt
--
Chapters
00:00 Can I Prevent Chrome From Truncating Strings In The Dev Console?
00:32 Answer 1 Score 3
00:43 Answer 2 Score 6
01:03 Accepted Answer Score 69
01:40 Answer 4 Score 4
01:50 Thank you
--
Full question
https://superuser.com/questions/699922/c...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#googlechrome
#avk47
Rise to the top 3% as a developer or hire one of them at Toptal: https://topt.al/25cXVn
--------------------------------------------------
Music by Eric Matyas
https://www.soundimage.org
Track title: Melt
--
Chapters
00:00 Can I Prevent Chrome From Truncating Strings In The Dev Console?
00:32 Answer 1 Score 3
00:43 Answer 2 Score 6
01:03 Accepted Answer Score 69
01:40 Answer 4 Score 4
01:50 Thank you
--
Full question
https://superuser.com/questions/699922/c...
--
Content licensed under CC BY-SA
https://meta.stackexchange.com/help/lice...
--
Tags
#googlechrome
#avk47
ACCEPTED ANSWER
Score 69
I recently discovered that the Chrome dev tools has a copy
function which copies to clipboard - without truncation! Handily it also serializes objects to JSON and DOM elements to HTML, straight to the clipboard.
copy(someLongString); // no truncation!
copy({ foo : true }); // JSON
copy(someDOMElement); // HTML
Since I was trying to copy a long string to clipboard for analysis elsewhere, this served my needs perfectly
Edit in 2021: Seems Chrome now adds a handy button in console for copying long strings:
Here's some code to test the feature:
var str = "";
// generate 30kb hex string
for(var i = 0; i < (1024 * 30); i++) {
str += (i % 16).toString(16)
};
// just so we know it copied the whole thing
str += "END";
ANSWER 2
Score 6
This behavior still exists in Chrome Version 37.0.2062.103.
You can get around this while debugging by using: document.write('My Really Long Debug Text');
ANSWER 3
Score 4
I use the following:
var text = 'a really long string';
window.prompt("Copy to clipboard", text);
then copy the text from the edit field.
ANSWER 4
Score 3
Upgrade Chrome to version 32 which no longer does this, as shown by this picture: