In theory, either would be acceptable. In practice, I would lean toward doing as much repetitious work on the server as possible. If you think about it in terms of which can do it faster, you KNOW how fast your server can do it. The resources stay (relatively) constant.
Doing it in javascript relies on the client environment. With a web application, the client environment is infinitely varied. You never know how much memory a client will have available, so it is impossible to estimate how efficiently they can parse the data. 99% of your clients might be fine, but the other 1% get a locked browser when they use your script.
The safest bet is always to use known quantities as much as possible. In this case, the sever is your known quantity - do the work there.