I want to convert the XDR fromat of the transaction to text using JS or java SDK in stellar.Or if there are any methods outside stellar also fine.
XDR is a binary encoding of structured data. It is represented as a base 64 encoded String in transaction responses.
You can decode base 64 encoded XDR using the laboratory.
If you can use the Scala SDK you can call
SignedTransaction.decodeXDR(base64)(TestNetwork)to get an object that you can inspect. (Eventually this will decode to case classes, which display all fields when printed - but it's not ready in the SDK yet) (Disclaimer: I am the author).
The following (untested) Java code deserialises the base 64 TransactionResponse to an object to the same as #3.
import java.io.ByteArrayInputStream; import java.util.Base64; import org.stellar.sdk.xdr.*; Byte bytes = Base64.getDecoder().decode(base64); XdrDataInputStream in = new XdrDataInputStream(new ByteArrayInputStream(bytes)); TransactionEnvelope.decode(in)