Users have the ability to enter and save text in a rich text editor which is eventually stored in a database and then rendered on a site.

Is it better to convert the RTF to HTML when it's stored to the database because there will be more reads than writes and converting it once will be more efficient?

Or would it be better to store the RTF directly in the database so the original data is always retained and there's more separation between data and display?

Convert to html on save to database:


  • More efficient when more there are more reads than writes
  • Faster retrieval/rendering


  • Takes up more storage space
  • Presentation and data mixed
  • Original output from editor lost

Convert to html on retrieval from database:


  • Keeps original data in-tact
  • Separates presentation from data


  • Inefficient/ must convert on every retrieval and render

Both seem options seem to come with costs/benefits so are there any established best practices or is it decision that needs to be made based on the specifics of each project?

  • 1
    Could you elaborate the pros and cons of both methods in your question? Dec 8, 2020 at 1:24
  • Updated the pros/cons
    – Coupcoup
    Dec 8, 2020 at 1:49
  • 3
    You're missing a third alternative: Keep both the original RTF version and the generated HTML. (This is what Stack Exchange does.) Dec 8, 2020 at 2:28
  • 1
    E.g. What if you decide you want to render to Markdown instead of HTML? If you store HTML, now you need to parse it back to some simpler form, and transform it back to markdown. If RTF is the simpler format of the two (IDK if it is), then I would store that.
    – Alexander
    Dec 8, 2020 at 19:15
  • That's definitely one of the benefits of preserving the original data. Per the other comment I implemented it this morning to store both rendered html and the rtf in the db. If it needs to change to markdown or something now it'd just be a short script to use the rtf field for each post to convert to the new format and update the rendered column
    – Coupcoup
    Dec 8, 2020 at 19:30

1 Answer 1


As ever, the most important decision about storing data is not about how to store data.

It's how you're going to use the data after you've stored it.

If you're going to have to read the HTML, convert it into RTF and then pass that into the editor (possibly losing something in the process), then that's a sizeable overhead over just reading and sending the RTF.
But, as you say, if you only "edit" once or twice and then "publish" hundreds of times, that overhead may not matter.

Personally, I'd keep with RTF until you need to "render" the finished, HTML version.

Would you really want a partially-edited version to get "published" before it was ready? (Say, with big, red notes in it like "the new stuff goes here!")? Probably not. In that case, "edit" is a separate activity from the "publish" and the data stored should be optimised for each.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.