How to convert from curve25519 33 byte to 32 byte representation According to the curve25519 paper a x25519 public key can be represented in 32 bytes.

The x25519 library I'm using (bouncycastle) however gives me a 33 byte representation according to this standard.

My 33 byte hex representation always begins with the hex 02 or 03.

How do I convert a 33 byte representation to a 32 byte representation?

And when I am provided with a 32 byte representation, how do I know whether to prepend 02 or 03 to it to convert it back to a 33 byte representation?
The second link you provided actually contains all the information you need:


  Note that ECPoint.point differs from the definition of public keys in [Curve25519] in two ways: (1) the byte-ordering is big-endian, wich is more uniform with how big integers are represented in TLS, and (2) there is an additional length byte (so ECpoint.point is actually 33 bytes), again for uniformity (and extensibility).


Beside of those two difference, the rest is the same.

Now, from BouncyCastle code, you can see that:

PO[0] = (byte)(normed.getCompressionYTilde() ? 0x03 : 0x02);
System.arraycopy(X, 0, PO, 1, X.length);


So, you are right, it will always begin with 0x03 or 0x02 and the actual $X$ value is contained as being the 32 last bytes on the getEncoded() return value. 
(According to the draft you linked, it will probably be in big-endian, so you might need to convert them into little-endian depending on why/how you need them.)