There are several of layers involved.
One is an evidence issue called "authentication" which in the federal rules of evidence is governed by Rules 901, 902 and 903. Many states have the same numbering system, but others insist on being different.
It is probably not possible to make this kind of material "self-authenticating" (i.e. allowed to be introduced into evidence at a trial without live testimony concerning its authenticity) but it probably is possible to document the origin of the material and have a credible person (usually you, a law firm staff person or an IT consultant) testify as a witness to the fact that the evidence presented to a court is authentic. Prior to trial this is usually done with an affidavit of someone with personal knowledge of the facts. At trial, usually an authentication witness would be called to testify if this issue isn't stipulated to (stipulations as to authenticity are routine unless there is a bona fide dispute over authenticity.)
Secondly, from a practical level, there are computer applications that make it possible to download text messages and similar electronic materials to a hard drive in its original format.
Third, there is the issue of proving that the authentic text messages actually come from the person you claim that they do. This is important for two reasons.
One reason is that a text message from your opponent in a lawsuit doesn't count as hearsay, but a text message from someone else is hearsay and not admissible unless it is within an exception to the hearsay rule. So proving who it came from my be necessary to get it into evidence once it is proved to be authentic.
The other reason is that you need to prove who it comes from, because the court needs to believe that in order for you to win on the point you want to prove with the messages.
The question of who it comes from is usually proved with evidence such as your testimony about the owner of the sender's account, testimony of the alleged sender, telephone company records, and evidence of how the timing of messages ties into the timing of other things that you can prove happened with other evidence.
You would also have to show that the evidence is relevant; in no fault divorce states, lots of evidence of misconduct by a spouse is not relevant and therefore not admissible.