I came across a question where user had copied the output of a certain command and made a *.docx file out of it. The file was uploaded and the link was provided in the question to this file.
I copied the output and tried to paste it in the question by using code block. But the file contained too many characters (approximately 80000) and I was not able to write it down in code block format.

I want to ask that if outputs like this (which have too many characters) can not be pasted in the code block then why should there be an option to use code block? I mean, the current limit of 30000 character is too much if you simply want to use it for pasting codes like this:

sudo apt install <package-name>
sudo apt update
  • If the sole purpose of using code block is to use 2-3 lines or may be 50-100 lines of code then why should there be a limit as high as 30000?

  • If things are otherwise then why should there be an upper limit?


As @JacobVlijm has commented, the upper limit should not be very high so as to attract spams. But what about keeping it less than 30000?

  • What parameters/aspects decide the upper limit set for code block?

  • Can't it be reduced to other value to make the questions more compact?

  • 4
    No one is ever going to read 30000+ chars of code, just to answer a question. It makes a question imo unreadable. This is not the place to spam with code (which would literally be an option if there was no limit). If you really think posting such amounts of code is needed, use pastebin. However, If information on specific lines of output are needed, anyone answering a question would ask to grep for anything. Commented Jan 27, 2017 at 6:54
  • That's my point. Why should there be limit of 30000? It is too high and can be kept at a low level, right? Commented Jan 27, 2017 at 7:03
  • 1
    ...I think 30.000 makes sense. It makes sure even substantial scripts can be posted (I looked, in some cases up to appr. 12000 chars were posted), while spam or insanely high amounts of code are prevented. Commented Jan 27, 2017 at 7:08
  • Ok, I am editing my question. Commented Jan 27, 2017 at 7:15
  • 4
    IIRC the 30k char limit does not apply to code blocks only but to the whole post in total.
    – Byte Commander Mod
    Commented Jan 27, 2017 at 7:28

1 Answer 1


Unless a new code-block-specific limit has been introduced recently (and not talked about), the limit is for the whole post, not specifically for a code block. If you pasted code in and didn't hit the limit, and then you formatted it as code and did hit the limit, that's because of the additional four spaces added to each line (which is how a line in a code block is signified in markdown). I've had that happen a couple times before, when improving the formatting on existing long posts.

If you decide you really do want to have that much text in a code block (or several code blocks), then a possible workaround is to use HTML rather than markdown to format it. You can put <pre><code> at the beginning of the first line of text that you want to format as code, and </code></pre> at the end of the last line.

If you do this, then you should make sure there isn't anything that's interpreted as HTML in the block itself, because unlike when you prefix every line with four spaces, characters like < do get interpreted specially inside <pre><code> tags you put in yourself. (This is actually the main use case for using those tags -- if you need to apply special formatting to code, for a purpose other than what automatic syntax highlighting will achieve.)

On the one hand, you might not want to have that much code in a post! But sometimes it may be reasonable to put lots of text from the terminal, or dmesg, or something in a post. Ubuntu Pastebin and other paste sites are handy and should definitely be preferred for truly enormous amounts of text (like, beyond the 30,000 character limit), but they do run the risk of creating what might be called a "link-only question"--there is no guarantee pastes will survive forever, even if they are never manually deleted. I believe it usually depends on how long it's been since they've been viewed.

A single code block on Ask Ubuntu is styled so it doesn't take up too much vertical space -- instead of getting tall, it gets a scroll bar. Eventually, posts will start to make the page lag on slower devices, but that's more a feature of what is in the post -- just a few animated images, for example, will probably cause more users' devices to lag on the page than 30,000 characters of text. There should be some limit to the length of a post, but it should not be short, because if it were then quite a few good-quality posts couldn't exist. For example, I would not want this answer to have been prevented from existing.

It's certainly possible for a whole answer to come up against the character limit, even a good answer that isn't needlessly long. This happens on the Stack Exchange network from time to time, especially for answers that need to provide lots of information, quoted from different sources, need to give their own explanatory context, and the URLs for the sources are themselves really long. I'm thinking particularly of this answer on English Language & Usage. But I'm not familiar with situations where the markdown of a post really needed to be quite that long here on Ask Ubuntu.

Unless there's evidence that anyone is having significant problems using the system to create good-quality posts, a simple limit of 30,000 characters seems reasonable to me. At least as of now, I don't think there's any reason to make it smaller (as you seem to be suggesting), or bigger, or to make things way more complicated by having a separate total or individual limit for code blocks. This isn't something that needs fixing.

  • Yes, I use <pre><code> tag. But as I see, part of the problem is due to the ignorance (I didn't know that the limit is for the question as a whole and not just the code; I admit it). And I liked the way you ended your answer with that link. Commented Jan 27, 2017 at 7:55

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .