Some programs to do this have been submitted for review, so you might be able to use one of them:
- java: Tool for creating CodeReview questions
java: Tool for creating CodeReview questions
- shell: Shell script for creating CR questions
shell: Shell script for creating CR questions
- javascript: Tool for automatically correcting indentation and formatting of CR & SO code
javascript: Tool for automatically correcting indentation and formatting of CR & SO code
This last one is also on JSFiddle
This last one is also on JSFiddle