Then create a paste and copy and paste your code there. You can select the language of you code from the syntax highlight drop down and give it a title.
Then click on submit button.
You will redirected to your paste. There on top you can see the link called “embed”. Click on it and you will see a script and iframe html code to embed your paste.
Copy the script tags and go to Tumblr and create a new text post. Select <html> button in the editor. Paste your script tags. Click on post.
When you go to your blog, you will be able to see the pasted code formatted beautifully.