Why is there an ASCII mode in FTP, which is prevalent in today's software and FTP implementations? Why not just always use binary regardless of the data?

migrated from stackoverflow.com Jul 16 '09 at 2:09

This question came from our site for professional and enthusiast programmers.


When in doubt, read the RFC:

File-structure is the default to be assumed if the STRUcture command has not been used but both file and record structures must be accepted for "text" files (i.e., files with TYPE ASCII or EBCDIC) by all FTP implementations. The structure of a file will affect both the transfer mode of a file (see the Section on Transmission Modes) and the interpretation and storage of the file.

The "natural" structure of a file will depend on which host stores the file. A source-code file will usually be stored on an IBM Mainframe in fixed length records but on a DEC TOPS-20 as a stream of characters partitioned into lines, for example by . If the transfer of files between such disparate sites is to be useful, there must be some way for one site to recognize the other's assumptions about the file.

etc etc ... In short, it is to ensure that text representations in one encoding got converted properly when transferred to hosts using a different encoding.

  • When in doubt: search Google and find the answer on StackExchange. – ke4ukz Jun 14 at 17:21

Because different operating systems (Windows, UNIX, VAX) use different line ending methods for simple text files.

Windows (DOS) uses a CR/LF pair, UNIX uses only one of them. ASCII mode converts CRLF pairs and BIN mode doesn't.


  • 4
    It's more than just the line ending encoding differences you mention, but it is also about the differences encoding of characters themselves such as the difference between ASCII and EBCDIC. The answer by @Sinan sites the specifics documented in RFC-959 – Tall Jeff Jul 16 '09 at 2:22

I think it's just because it sometimes is convenient. Back in the day when FTP was how you got files from one system to the next, it was a big timesaver -- you didn't have to know what the system was on the other end in order to have a readable text file.

But yeah, mostly it's just a nuisance today. Just a corrupt-o-matic machine for the uninitiated!


ASCII mode had its place back in the day when character and EOL encoding was a real problem, but I would like to see ftp clients remove or perhaps just hide this option today. Nowdays it's mostly just EOL conventions that get messed up between systems, but I've found most decent text editors don't care anymore anyway. So in order to avoid corrupting binary files (or even some text based ones), I recommend just using binary mode for everything.


ASCII mode is used so that the software can automatically change EOL characters to the proper values for the client/server depending on if you are uploading/downloading. If you are uploading to the same type of system as you are using, there is no difference in these modes.

The reason for this mode though is because not all software on all systems will correctly handle EOL's that aren't the exact proper type of EOL (for instance, alot of Windows software will only handle "\r\n" properly and will balk something horrible on "\n").

  • "there is no difference in these modes." - This is not true. Sending a binary file in ascii mode is likely to corrupt it. Badly. – Beefster Dec 11 '18 at 23:38

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.